Codreanu Andrei
Codreanu Andrei

Reputation: 48

Height Item on ListView not change

I have to change the height of the cell in list view , but i couldn't find where is defined this height in my project. I look at the XML file that holds the list_view_item.xml but what ever i change there, has no result. I even change the entire xml file with my own xml file but the height is still huge. Where else i can find this height defined. I'm working with fragments that are dinammicaly added to a view container.

I search for my problem but i don't find a answer for this. Here is my XML defining an item:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/splash_ll"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingBottom="0dp"
android:paddingLeft="5dp"
android:weightSum="3.5" >

<ImageView
    android:id="@+id/splash_list_img"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:maxHeight="@dimen/max_height"
    android:minHeight="@dimen/min_height"
    android:scaleType="fitXY"
    android:src="@drawable/s0" />

<TextView
    android:id="@+id/splash_list_txt"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="2"
    android:ellipsize="marquee"
    android:gravity="center|left"
    android:padding="5dp"
    android:singleLine="true"
    android:textSize="@dimen/text_size"
    android:textStyle="bold" />

<ImageView
    android:id="@+id/splash_list_bookmark"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight=".5"
    android:adjustViewBounds="true"
    android:gravity="center|left"
    android:scaleType="fitCenter"
    android:padding="5dp"
    android:src="@drawable/bookmark_normal" />

</LinearLayout>

Where/How this height can elsewhere be defined. Thanks in advance!

Upvotes: 0

Views: 564

Answers (2)

Codreanu Andrei
Codreanu Andrei

Reputation: 48

I finally find the source of the problem, in the adapter in getView method, when the XML File is inflated i have this error : "Avoid passing null as the view root" (R.layout.bookmark_list_view, null) and has to be changed with : layoutInflater.inflate(R.layout.bookmark_list_view, parent, false); , in order to have any effect the list_view_item.xml root height change.

I hope this answer could help others in the future.

Upvotes: 1

Phiat
Phiat

Reputation: 506

Since it's a ListItem, you don't want the LinearLayout's layout_height attribute to be set to "fill parent"; Instead try setting it to "wrap_content"

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/splash_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="0dp"
android:paddingLeft="5dp"
android:weightSum="3.5" >

If this does not fix your problem, elaborate on the situation and I might be able to help more.

Good luck!

Upvotes: 0

Related Questions