画面いっぱいにViewを配置する方法
Androidは機種ごとに画面サイズがばらばらです。
なのでどの環境でも同じようにボタンなどのビューを表示する方法の1つとして画面いっぱいにビューを配置することがあります。
例えば、1つのLinearLayoutの中に3つのボタンを入れるようなレイアウトがあるとします。
その3つのボタンで画面全体を埋めるには次のレイアウトを書きます。
<?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" >
        
    <Button
        android:id="@+id/button1" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:text="Button" />
    <Button
        android:id="@+id/button2" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:text="Button" />
    <Button
        android:id="@+id/button3" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:text="Button" />
</LinearLayout>
それぞれのボタンのwidthとheight属性を"fill_parent"にし、weight属性を"1"に設定することで同じ幅と高さでボタンが画面いっぱいに表示されます。
もちろんこのような縦方向だけではなく横方向のレイアウトでも同じことができます。
© Kaz