Reputation: 16245
Below is an image of a ListView
row that is too short. I've tried too many combinations and yield my frustration to StackOverflow.
How can I fix this and show the whole row? Here is the XML for the item.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:weightSum="1">
<LinearLayout android:id="@+id/item_left"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:background="@drawable/item_left"
android:layout_gravity="fill_vertical">
<TextView
android:id="@+id/status_day"
android:layout_gravity="center_vertical"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:textColor="@color/item_left_text"
android:textSize="25sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="2dp"
android:background="@drawable/item_right"
android:layout_weight="1">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/item_right_text"
android:text="" />
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/item_right_text"
android:text="" />
</LinearLayout>
<ImageButton
android:id="@+id/options"
android:background="@drawable/item_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_menu_moreoverflow_normal_holo_light"
/>
</LinearLayout>
Any help is appreciated.
Upvotes: 2
Views: 7477
Reputation: 7605
your layout should be in such manner for your requirement i have pasted not same as your's layout but related to it check it
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="60dp" >
<ImageView
android:id="@+id/ivArrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:focusable="false"
android:clickable="false"
android:src="@drawable/arrow" />
<RelativeLayout
android:id="@+id/ivIcon"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:focusable="false"
android:clickable="false"
android:background="@drawable/oddnumbg" >
<TextView
android:id="@+id/tvNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textColor="@color/ReceiptNoLable"
android:text="No." />
<TextView
android:id="@+id/tvReceiptNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:singleLine="true"
android:layout_below="@+id/tvNo"
android:gravity="center"
android:textColor="@color/ReceiptSavedColor"
android:textSize="18dp"
android:text="1234" />
</RelativeLayout>
<TextView
android:id="@+id/tvSubName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/ivIcon"
android:text="RECEIVED FROM"
android:gravity="center"
android:focusable="false"
android:clickable="false"
android:textColor="@color/ReceiptNoLable"
/>
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/ivIcon"
android:layout_below="@+id/tvSubName"
android:text="RECEIPT"
android:layout_marginLeft="15dp"
android:textColor="@color/ReceiptSavedColor"
android:textSize="30dp"
android:focusable="false"
android:layout_toLeftOf="@+id/tvReceiptPrize"
android:clickable="false"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tvReceiptPrize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/ivArrow"
android:background="@drawable/myreceiptprizebg"
android:gravity="center"
android:singleLine="true"
android:layout_marginRight="5dp"
android:textSize="20dp"
android:textColor="#fff"
android:text="$84.20" />
</RelativeLayout>
</LinearLayout>
Upvotes: 3
Reputation: 16245
I set the height of the ImageButton
to match_parent
.
This fixed the issue oddly. Sigh.
Upvotes: 3
Reputation: 22493
can you use this, set row layout height
android:layout_height="?android:attr/listPreferredItemHeight"
Upvotes: 5
Reputation: 10190
just set the height of the outer layout, instead of using fill_parent
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:awesome="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height=50dp <!-- or anything which fits -->
Upvotes: 1