Reputation: 195
i have a problem with my custom ListView. The items in the list dont fit with the width of the list and i dont know why.
Maybe the picture helps you.
ListView:
android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">
<LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="match_parent" android:gravity="center_vertical" android:background="#626262">
<AutoCompleteTextView android:id="@+id/autoCompleteTextView1" android:layout_width="match_parent" android:layout_weight="2" android:layout_height="45dip" android:layout_marginTop="2dip"></AutoCompleteTextView>
<ImageView android:id="@+id/imageView1" android:src="@drawable/lupe" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout2" android:layout_width="wrap_content" android:layout_height="match_parent">
<ListView
android:id="@+id/android:list"
android:background="#000000"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#FFFFFF"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Row:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<ImageView
android:id="@+id/image"
android:layout_width="50dip"
android:layout_height="50dip"
android:src="@drawable/icon"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/Buddystoptext"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:textSize="20dip"
android:layout_marginLeft="10dip"
android:text="Text"
android:layout_width="match_parent" />
</LinearLayout>
OnClick xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_deselect" />
<item android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_focus" />
<!-- Focused states -->
<item android:state_focused="true"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_deselect" />
<item android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_focus" />
<!-- Pressed -->
<item android:state_pressed="true"
android:drawable="@drawable/msg_bg_focus" />
</selector>
Can anybody help ?
Thank you.
Upvotes: 1
Views: 764
Reputation: 1465
Gregory is right. Fill parent. But if that is an image your gonna have to do some 9-patch work as well. Depending on how your images are setup for scale.
Upvotes: 0
Reputation: 4424
Your item's layout should have layout_width set to fill_parent instead of wrap_content.
Upvotes: 1