For an intro page, for an Android app, I want to make 9 buttons in this order:
[img1][img2][img3]
[img4][img5][img6]
[img7][img8][img9]
There is a whitespace between every image(10dp)
The problem, when I’m using LinearLayouts, there always is a white space. Same for a table.
I cannot use a GridLayout because the app needs to support Android 2.2
I hope you could help me!
P.S.
Here is an example of the code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/tl"
android:layout_width="220dp"
android:layout_height="220dp"
android:src="@drawable/home_tl" />
<ImageView
android:id="@+id/ImageView05"
android:layout_width="220dp"
android:layout_height="220dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/home_tc" />
<ImageView
android:id="@+id/ImageView06"
android:layout_width="220dp"
android:layout_height="220dp"
android:src="@drawable/home_tr" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/ImageView01"
android:layout_width="220dp"
android:layout_height="220dp"
android:src="@drawable/home_ml" />
<ImageView
android:id="@+id/ImageView02"
android:layout_width="220dp"
android:layout_height="220dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/home_mc" />
<ImageView
android:id="@+id/ImageView03"
android:layout_width="220dp"
android:layout_height="220dp"
android:src="@drawable/home_mr" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="220dp"
android:layout_height="220dp"
android:src="@drawable/home_bl" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="220dp"
android:layout_height="220dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/home_bc" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="220dp"
android:layout_height="220dp"
android:src="@drawable/home_br" />
</LinearLayout>
</LinearLayout>
The problem is that the images not fit in the screen. It must be suitable for every size (even for tablets 10.1)
Solved:
I added for every imageview android:adjustViewBounds="true" and used layout_weight="1"
try using LinearLayout with horizontal orientation and inside that,take 3 ImageButtons and keep the width of each as fill_parent and weight = 1,this will give equal width to all the 3 imageButton.
for eg