2011-04-13 107 views
0

我怎麼會在下面的佈局位置圖片...Android:定位圖像?

|----------------------| 
|      | 
|      | 
| I    I | 
|      | 
|      | 
|      | 
|      | 
|      | 
| I    I | 
|      | 
|      | 
------------------------ 

其中每個i =一個ImageView的。

+0

@ user596186:你看過GridView嗎? – Squonk 2011-04-13 15:02:29

回答

1

您可以使用TableLayout,RelativeLayout或嵌套的LinearLayouts。所有的圖像都是相同的大小,你想讓它們填滿屏幕嗎?

1

將您的主佈局設置爲水平。將兩個新佈局Layout1,Layout2添加到您的mainlayout。將它們都設置爲veritcal佈局。將2個圖像瀏覽添加到layout1和2個圖像瀏覽到layout2。

1

試試這個:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" android:layout_height="match_parent"> 
    <ImageView android:layout_height="wrap_content" android:src="@drawable/icon" 
     android:id="@+id/imageView1" android:layout_width="wrap_content" 
     android:layout_alignParentLeft="true" android:layout_alignParentTop="true"></ImageView> 
    <ImageView android:layout_height="wrap_content" android:src="@drawable/icon" 
     android:id="@+id/imageView2" android:layout_width="wrap_content" 
     android:layout_alignParentRight="true" android:layout_alignParentTop="true"></ImageView> 
    <ImageView android:layout_height="wrap_content" android:src="@drawable/icon" 
     android:id="@+id/imageView3" android:layout_width="wrap_content" 
     android:layout_alignParentLeft="true" android:layout_alignParentBottom="true"></ImageView> 
    <ImageView android:layout_height="wrap_content" android:src="@drawable/icon" 
     android:id="@+id/imageView4" android:layout_width="wrap_content" 
     android:layout_alignParentRight="true" android:layout_alignParentBottom="true"></ImageView> 
</RelativeLayout> 
如果你想拉的圖像從邊緣,只是採用的Android

:layout_margin *屬性個別ImageView的控制。