Reputation: 2191
I designed following layout. Works pretty fine on emulators of all size except wxga screen. I also tried it on my tegra 2 powered Toshiba AC100 but buttons are not aligned to right of the screen instead it shrinks and visible just right of textview. It looks fine on my brother's HVGA xperia mini ST15i.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow android:id="@+id/tableRow">
<ImageView android:id="@+id/image"
android:layout_width="32dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp"
android:layout_height="32dp"
android:focusable="false"
android:focusableInTouchMode="false" />
<TextView android:id="@+id/text"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:padding="10dp"
android:focusable="false"
android:focusableInTouchMode="false" />
<Button android:id="@+id/button"
android:layout_width="60dp"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/button"
android:focusable="false"
android:focusableInTouchMode="false" />
</TableRow>
</TableLayout>
Upvotes: 1
Views: 477
Reputation: 2191
I figure out layout for listview with imageview, textview and button. It works very well under different screen orientation and size.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:id="@+id/relativeLayout"
android:layout_height="wrap_content">
<ImageView android:id="@+id/drawable_icon"
android:layout_width="36dp"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_alignParentLeft="true"
android:layout_height="36dp"
android:focusable="false"
android:focusableInTouchMode="false" />
<TextView android:id="@+id/text"
android:layout_toRightOf="@id/drawable_icon"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginRight="65dp"
android:focusable="false"
android:focusableInTouchMode="false" />
<Button android:id="@+id/button"
android:layout_width="60dp"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:text="@string/buttonText"
android:focusable="false"
android:focusableInTouchMode="false" />
</RelativeLayout>
Upvotes: 1
Reputation: 3804
maybe you can use LinearLayout for the parent of ImageView, TextView, and Button. In LinearLayout use horizontal orientation. If you want the child to be visible in all situation, you can add android:layout_weight="1" attribute in ImageView, TextView, and Button.
Upvotes: 0