Viewを画面の一番下に配置する方法
OK/キャンセルとか保存など、画面の一番下にボタンを配置したい時がある。
そのような場合のレイアウトの書き方。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > // 上の方に配置するViewを書く <LinearLayout android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center|bottom" android:orientation="vertical" > <Button android:id="@+id/hoge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="@string/hoge" /> </LinearLayout> </LinearLayout>