I have a ListView with an ArrayAdapter which uses an XML layout, similar to simple_list_item_1, to inflate its content. I have two options in the app menu to increase/decrease the text size. I managed to modify the text size of the TextViews inside the ListView by overriding the getView function of the ArrayAdapter. Something like this:
adapter = new ArrayAdapter<Line>(MyActivity.this, R.layout.line_list, lines){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = (TextView) super.getView(position, convertView, parent);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSizeDp + zoom);
return textView;
}
};
listView.setAdapter(adapter);
The menu options change the zoom value and call adapter.notifyDataSetChanged(); to make the adapter change the text size.
Until that point everything works.
The problem is that when I decrease the text size too much, the height of each TextView is not wrapping its content. That is, the ListView items are too high. When I increase the text size I don’t have problems with the items height.
If I call super.getView(position, convertView, parent); with convertView being null, I make the adapter to allways inflate. In that case, decreasing the text size works fine since the height is wrapped. However, I’m causing an overload of work and I don’t want that.
I tried invalidating or forcing layout to the listview and/or the textviews but it didn’t work.
Any help is appreciated
EDIT: This is line_list layout:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/lineTextSize"
android:gravity="center"
android:paddingLeft="6dip"
android:paddingRight="6dip" />
lineTextSize is 22dp for default and 40dp for large
EDIT 2: Look like this
instead of this screen: 
I found here that this is a known bug for Android 3.1+
The solution is to add a string like this
to the text of the TextViews. So, the correct
getViewfunction of the adapter is: