2017-10-05 46 views

回答

2

你可能會尋找預覽不同的屏幕尺寸比手機的設備。

要在所有設備中將圖像均分爲3部分,可以使用GridView/GridLayout或使用帶有權重的LinearLayout。

0

試試這個:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:weightSum="3" > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:orientation="horizontal" 
    android:weightSum="3" > 

    <ImageButton 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageButton 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageButton 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:orientation="horizontal" 
    android:weightSum="3" > 

    <ImageButton 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageButton 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageButton 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:orientation="horizontal" 
    android:weightSum="3" > 

    <ImageButton 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageButton 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageButton 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 
</LinearLayout>