2

2つのImageButtonがあり、一方を他方の上にスタックしようとしています。基本的に、それぞれが使用可能なスペースの50%を占める2つの大きなボタンを備えた画面を作成したいと思います。コードは以下のとおりです。これは、それが生成するレイアウトのキャプチャですhttp://imgur.com/cQT0W.png私が親のlayout_gravityとgravityで遊んだことがあります。layout_height = fill_parentで両方の子を設定しても機能せず、親の重力をfill_verticalに設定することもできません。

        <!-- Notes tab -->
        <LinearLayout android:id="@+id/tabNotes"  
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"             
            android:padding="6dp"
            android:orientation="vertical">                                                 
            <ImageButton android:src="@drawable/ic_btn_speak_now" android:id="@+id/imgSpeakNow"                         
                android:background="#FFFF00"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                />                  
            <ImageButton android:src="@drawable/ic_btn_compose" android:id="@+id/imgCompose" 
                android:background="#FF00FF"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"                                    
                />
        </LinearLayout>
4

1 に答える 1

1

android:layout_weight; を使用します。両方のボタンを同じ値に設定します。

LinearLayout の代わりに RelativeLayout を使用することも役立つ場合があります。

于 2010-07-22T19:37:12.630 に答える