I have a LinearLayout that works great to produce something like:
[ fixed image size ] [ fixed image size ] [ text takes up the space that is left ]
The XML looks similar to:
<?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="wrap_content" >
<ImageView
android:id="@+id/image1"
android:layout_width="50dp"
android:layout_height="120dp"
android:layout_gravity="center_vertical" />
<ImageView
android:id="@+id/image2"
android:layout_width="263dp"
android:layout_height="150dp"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:paddingRight="5dip"
android:textColor="#ffffffff"
android:textSize="13sp" />
</LinearLayout>
Now I want to reverse it, have another view that looks like:
[ text takes up space that is left ] [ fixed image size ] [ fixed image size ]
So I naturally did the obvious thing which is:
<?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="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:paddingRight="5dip"
android:textColor="#ffffffff"
android:textSize="13sp" />
<ImageView
android:id="@+id/image1"
android:layout_width="50dp"
android:layout_height="120dp"
android:layout_gravity="center_vertical" />
<ImageView
android:id="@+id/image2"
android:layout_width="263dp"
android:layout_height="150dp"
android:layout_gravity="center_vertical" />
</LinearLayout>
But in this case, the text just goes over the entire width, because width is fill_parent.. but I don’t want it to wrap_content either.
Is there any easy way to do this?
Set textview1’s width to 0dp and add a layout_weight element = 1.