0

I have an app that allows the user to change the text size. On Android 2.X when you made the text smaller the vertical spacing got smaller too. On 4.X the text gets smaller and the spacing remains the same.

The call that I am using to change the size is (there is a loop to change multiple lines):

tvData[i].setTextSize(TypedValue.COMPLEX_UNIT_PX, fSize);

The text fields are described in main.xml as follows (there is more than one and they are each "below" the previous one.

<TextView android:id="@+id/textOut1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:typeface="monospace"
    android:textSize="28dip"
    android:textColor="#000000"
    android:textStyle="bold"
    android:layout_below="@id/textOut0"
    />

What do I have to do so this works in both old and new Android?

Darshan Rivka Whittle
  • 32,989
  • 7
  • 91
  • 109
TomZ
  • 7
  • 2
  • 6

1 Answers1

0

The fix was to not put each line of text in a separate TextView. By putting all of the text in one TextView and ending each line in a newline it now adjusts vertical spacing when the font size is changed.

And the change to one has been tested to work on older versions of Android too.

I cannot remember why I used an array of TextViews in the first place, seems like a bad choice looking at it now, but it did work with older versions.

TomZ

TomZ
  • 7
  • 2
  • 6