2011-11-15 7 views
0

なぜ中ボタンが消えますか?親の幅をすべて埋めるためにストレッチするのではなく、それに対して、layout_height = 0dpに設定すると、それは高さで行い、親を埋めるのですか?layout_weightを使用しています

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 
<Button 
    android:id="@+id/button1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"   
    android:text="Button" /> 

<Button 
    android:id="@+id/button2" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:text="Button" /> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"   
    android:text="TextView" /> 

+0

画像を描画して、ここに画像をアップロードできますか? – Pratik

答えて

3

リニアレイアウト方向が垂直であるので、唯一残っている高さはlayout_weightが「1」であれば、方向はここで重要である占有されます。幅を共有したい場合は、向きを「水平」に変更することができます。あなたの子供たちは水平に置かれることに留意してください。

+0

+1、それは理由です。 –

関連する問題