-2

i am having problem in adjusting with program spacing. as i am taking numbers from user like random numbers 2 4 7 1 9.. as the space size of space character and star characters are different. the view of my result is not as i want. like in 2 4.. the stars above 4 after 2 is not in a proper vertical row.. here is a screenshot: stars pattern

Do send the solutions to make the output exactly in vertical row

public void show(View v)
{

    for(int i:al)
    {
        item=i;
        total++;
        if(item>max)
            max=item;

    }
    value=new int[al.size()];
    maxindex=al.indexOf(max);
        for(int i=0;i<total;i++)
        {
            value[i]=al.get(i);

        }


        for(int i=1;i<=max;i++)
    {
        for(int j=0;j<total;j++)
        {
            if(i>max-value[j])
            {
                sb.append('*');
            }
            else
                //while(i<=max-value[j])

            {   
                sb.append(' ');

            }

        }
        sb.append("\n");
    }
    for(int i=0;i<total;i++)
    {
        ar.append(value[i]);
    }

        show.setText(sb+"\n"+ar);


}**strong text**
boisvert
  • 3,679
  • 2
  • 27
  • 53
  • here is the screenshot link http://postimg.org/image/s2xy38qd9/ – user3258080 Feb 20 '14 at 18:20
  • Even with the screenshot, I don't understand how you want the result. Is the screenshot the result you want or the result you have got (and need to improve)? Get precise about the specification of your exercise. – boisvert Feb 20 '14 at 18:47
  • 1
    screenshot is the result i got in output. suppose the result in rows and columns. the output should be in exact column or u can say in a vertical column.my output stars are bending towards left side,which i don't want to. – user3258080 Feb 27 '14 at 07:28

1 Answers1

2

In your XML, for your view add this line.

android:typeface="monospace" 

It is possible to do what you want with other font's even if they are not evenly spaced, but it's extremely complicated.

I hope this helps.

Merlevede
  • 8,140
  • 1
  • 24
  • 39