I thought I have understood the XML layout of Android, but it seems that I haven’t.
I want to have four ImageViews on one screen, to view four images at the same time.
It should look like this, where A to D represents the image views:
DDDAAA
DDDAAA
BBBCCC
BBBCCC
How can I do that? I tried it this way, but it’s not working. The Eclipse Editor seems not to be very good for this either. Is there a better one to create those layouts ?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableRow>
<ImageView android:id="@+id/ImageView01" android:layout_height="wrap_content" android:layout_width="wrap_content" ></ImageView>
<ImageView android:id="@+id/ImageView02" android:layout_height="wrap_content" android:layout_width="wrap_content"></ImageView>
</TableRow>
<TableRow>
<ImageView android:id="@+id/ImageView03" android:layout_height="wrap_content" android:layout_width="wrap_content"></ImageView>
<ImageView android:id="@+id/ImageView04" android:layout_height="wrap_content" android:layout_width="wrap_content"></ImageView>
</TableRow>
</RelativeLayout>
What about :
LinearLayout, withverticalorientation, that would contain everythingLinearLayout, withhorizontalorientationLinearLayoutwithhorizontalorientation, a second time, for B and CAnd using
android:layout_weightandroid:gravity="center"so each Layout takes enough place and is centered ?
A bit like this, I’d say :
I suppose (not tried) that you could even remove the
LinearLayoutthat’s just arround eachImageView, adding the attributes it has to theImageViews instead…(In the application I took this from, I had to add those
LinearLayoutbecause there are more than only those images)