2012-02-16 18 views
2

私はおそらく単純ですが、私はそれを理解していないようだ。私が探しているものの例は、4つのボタンがあるスクリーンです。 1つは左上象限全体を、2つは右上象限全体をとり、3つ目は左下象限全体をとり、4つ目は右下象限全体をとる。最終的には、4つのボタンが画面全体に表示されます。Androidのレイアウトと同じ幅と高さ

画面の幅を埋めるようにオブジェクトを均等に伸ばしたり、オブジェクトを伸ばして高さを埋めることができます。私が理解できないようなことは、同時に幅と高さを伸ばす方法です。

これについてのお手伝いがあれば幸いです。

答えて

3

私はあなたが1つのLinearLayoutでこれをしようとしていると思います。おそらく2つのLinearLayoutsを使って処理しています。何かのように:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1"> 
     <Button 
      android:layout_width="0dip" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 
     <Button 
      android:layout_width="0dip" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1"> 
     <Button 
      android:layout_width="0dip" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 
     <Button 
      android:layout_width="0dip" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 
    </LinearLayout> 
</LinearLayout> 

ちょうどそれがテストされ、それは間違いなく動作します。 LINTによれば、ネスティングのウェイトはパフォーマンスに悪いと言われていますが、間違いなく正しいレイアウトを持っています。