3

I have a ListView with some custom layout for the row (an image, then two lines of text using two TextView in a vertical LinearLayout, see code below)

My problem is that when I dynamically change the text size (in the getView method of the Adapter), the text size does change, but the size of the TextView that wraps it doesn't.

Here is a picture of what it does when I set the size to something "higher" than the default (picture is with 18). Despite the large number of threads or questions that seem similar, I haven't found a solution to that.

screen capture

Here is the layout of my list row:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="horizontal"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:padding="4dp">

    <ImageView android:id="@+id/entries_list_item_icon"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginRight="6dp"/>

    <LinearLayout android:orientation="vertical"
              android:layout_width="0dip"
              android:layout_weight="1"
              android:layout_height="fill_parent">
        <TextView android:id="@+id/entries_list_item_name"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:gravity="center_vertical"
              android:textColor="@color/entries_list_item_name"/>
        <TextView android:id="@+id/entries_list_item_summary"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:singleLine="true"
              android:ellipsize="marquee"
              android:textColor="@color/entries_list_item_summary"/>
    </LinearLayout>

</LinearLayout>

I tried switching the heights to 0dip as suggested elsewhere, it didn't change a thing.

EDIT The ListView itself is very basic:

    <ListView android:id="@+id/entries_list"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"/>
Guillaume
  • 22,694
  • 14
  • 56
  • 70
  • Have you tried changing your `height` attributes to `wrap_content` – litterbugkid Jan 08 '12 at 00:51
  • The only one that's not at wrap_content is the vertical LinearLayout, all the other ones already are. And yes, I did try changing this one too (I just tried again), no change - the LinearLayout wraps around the two TextView, but each of the TextView has an incorrect size already... – Guillaume Jan 08 '12 at 00:54
  • Sorry I meant `width` attribute! But now I'm seeing that's probably not your problem. – litterbugkid Jan 08 '12 at 00:56
  • No, I'm fine with the width being "too wide for the screen", I just want the height of the TextViews (and the whole List item) to be modified as required. – Guillaume Jan 08 '12 at 00:58

1 Answers1

3

I think you will have to change imageview height to fill_parent. Imageview is dictating the height of your layout.

<ImageView
  android:id="@+id/entries_list_item_icon"
  android:layout_width="wrap_content"
  android:layout_height="fill_parent"
  android:layout_marginRight="6dp" />
Abdul Rahman
  • 2,097
  • 4
  • 28
  • 36
nandeesh
  • 24,740
  • 6
  • 69
  • 79