一般的に言えば、ウィジェットのサイズに寸法を使用することは避けたいと考えています。やむを得ない場合、または推奨される場合もありますが、そのように「流動的な」レイアウトを作成することは困難です。
画面の特定の割合を占めるウィジェットが必要な場合は、LinearLayout
とandroid:layout_weight
を使用し、重みを使用して使用可能なスペースを割り当てます。
<?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">
<Button
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="50"
android:text="@string/fifty_percent"/>
<Button
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="30"
android:text="@string/thirty_percent"/>
<Button
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="20"
android:text="@string/twenty_percent"/>
</LinearLayout>