1

これに関する多くの投稿を見て、多くの解決策を試しましたが、何らかの理由で何も機能していません. ボタンが同じスペースを共有するようにしたいだけです...私のxmlコードを見て、何か問題があるかどうかを確認してください。ありがとう!

    
        
        
        
        

<ScrollView android:id="@+id/scrollview1" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:weightSum="120"> <Button android:id="@+id/btn_mission" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Mission"> </Button> <Button android:id="@+id/btn_news" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="News/Events"> </Button> <Button android:id="@+id/btn_studentservices" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Student Services"> </Button> <Button android:id="@+id/btn_facultyservices" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Faculty Services"> </Button> <Button android:id="@+id/btn_staff" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Staff"> </Button> <Button android:id="@+id/btn_library" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Library"> </Button> </LinearLayout> </ScrollView> </LinearLayout>

編集:背景を設定することと関係があるようです。背景を削除し、スクロールする必要があることを除いて、すべてが等しいスペースを共有しました。

4

2 に答える 2

2

すべてのボタンでを削除android:weightSum="120"してから設定してみてください。android:layout_weight="20"android:layout_weight="1"

于 2011-02-03T17:47:45.340 に答える
1

LinearLayout には垂直方向があるため、代わりにandroid:layout_width="0dp"を使用する必要がありますandroid:layout_height="0dp"

于 2011-02-03T17:38:33.340 に答える