2012-01-09 7 views

答えて

2

あなたがボタンを等しくすると、デバイスの画面の幅に応じて、それらを合わせてandroid:layout_weightを使用することができます。 4つのボタンすべてにandroid:layout_weight="1"を適用することができます。

+1

いいソリューション@Lalitです。 – Mihir

1

LinearLayoutandroid:weightSum="1.0"を使用し、android:layout_weight = "0.25"を4ボタン(weight_sum/no of buttons)にそれぞれ割り当てます。 layout_width = "fill_parent" アンドロイド:layout_weight_sum = "4"
アンドロイド:layout_width = "fill_parent" アンドロイド:あなたは
アンドロイドリニアレイアウトはもちろんの相対的なレイアウトの下

0

すべてのボタンのlayout_weight = "1" と彼らの親のレイアウト

それは私のために働く。

0

これは上記の質問に直接関係していませんが、私の回答も参考になると思います。 アプリケーションのフッター領域に2つのアイコンを配置したかったのです。ここに私がしたことがあります。

<LinearLayout 
    android:id="@+id/linearLayout2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" > 

    <ImageButton 
     android:id="@+id/back_arrow" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="16dp" 
     android:layout_weight=".5" 
     android:background="@android:color/transparent" 
     android:contentDescription="@string/Description" 
     android:onClick="onClickBtn" 
     android:layout_margin="35dp" 
     android:src="@drawable/backbut" /> 

    <ImageButton 
     android:id="@+id/imageButton2" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight=".5" 
     android:layout_margin="35dp" 
     android:background="@drawable/copy" 
     android:contentDescription="@string/Description" 
     android:onClick="onClickBtn" /> 
</LinearLayout> 

私は同じ幅を与えたいと思ったので、私は、Android設定されている:layout_weight =」5" と私は2つのアイコンamoung余裕を持っていると思いました。それで私はandroid:layout_margin = "35dp"を設定しました。

関連する問題