I have created a Listview. Each row contains an ImageView , TextView and an ImageButton.
I want the ImageButton to be of fixed size irrespective of the TextView's text length.
This is supposed to be simple but i could not get it to work.
Here is my layout file.
https://i.stack.imgur.com/C3jFa.png
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="@+id/androidAccountImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:src="@drawable/droidalt" />
<TextView
android:id="@+id/profileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_toRightOf="@id/androidAccountImage"
android:bufferType="spannable"
android:ellipsize="end"
android:gravity="center_vertical"
android:singleLine="true"
android:text="@string/strTryDemo"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageButton
android:id="@+id/androidProfileEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:layout_toRightOf="@+id/profileName"
android:src="@drawable/edit_account_button" />
</RelativeLayout>
Thanks.
Try the layout below: