Button
Android アプリケーションの上部または下部にバーを配置するにはどうすればよいですか?
つまり、Activities
私のアプリケーションではButton
、それらすべてにバーが必要です。
すばやくアクセスできるバーButtons
(ホーム ボタン、別の終了ボタンなど)
これはどのように実装できますか?
どうもありがとうございます
Button
Android アプリケーションの上部または下部にバーを配置するにはどうすればよいですか?
つまり、Activities
私のアプリケーションではButton
、それらすべてにバーが必要です。
すばやくアクセスできるバーButtons
(ホーム ボタン、別の終了ボタンなど)
これはどのように実装できますか?
どうもありがとうございます
を使用して、親の下部または親の上部にRelativeLayout
配置できます。Views
View
View
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativelayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="left top of parent" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="right top of parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="left bottom of parent" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="right bottom of parent" />
</LinearLayout>
</RelativeLayout>
できることは、そのボタン バーの新しいクラスを作成し、その UI 要素をすべての画面に含めることです。この概念はフラグメントと呼ばれます。フラグメントのコードを一度変更すると、他のすべての画面に反映されます。 ここにフラグメントのチュートリアルがあります。