画面解像度に関係なく、下部に 2 つのボタンを配置する必要があるアプリケーションを開発しています。
これを実装するには何が最善でしょうか?
画面解像度に関係なく、下部に 2 つのボタンを配置する必要があるアプリケーションを開発しています。
これを実装するには何が最善でしょうか?
RelativeLayout with下部にaを使用しLinearLayoutます。それを行う1つの方法で、layout_weight同じサイズのボタンを設定するために使用します。
更新しました
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" >
    <Button
        android:id="@+id/idBtn1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button 1" />
    <Button
        android:id="@+id/idBtn2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button 2" />
</LinearLayout>
これらのボタンを新しいレイアウト内に設定します(相対/線形-レイアウトビューにそれぞれ)、android:layout_alignParentBottom="true"
フッターを一般的に使用するには、次の方法を試してください。
footer.xml最初に 1 つのファイルを作成します。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >   
        <LinearLayout
            android:id="@id/idFooterMenu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true">
            <Button
                android:id="@+id/footerBtn1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Button1" />   
            <Button
                android:id="@+id/footerBtn2"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Button2" />
        </LinearLayout>
</RelativeLayout>
そして、コードを再度繰り返さずfooter.xmlに、このファイルを他の画面で使用できます。
<include layout="@layout/footer" />
ありがとう。