0

ButtonAndroid アプリケーションの上部または下部にバーを配置するにはどうすればよいですか?

つまり、Activities私のアプリケーションではButton、それらすべてにバーが必要です。

すばやくアクセスできるバーButtons(ホーム ボタン、別の終了ボタンなど)

これはどのように実装できますか?

どうもありがとうございます

4

2 に答える 2

1

を使用して、親の下部または親の上部にRelativeLayout配置できます。ViewsViewView

<?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>

ここに画像の説明を入力

于 2012-07-16T19:59:55.210 に答える
0

できることは、そのボタン バーの新しいクラスを作成し、その UI 要素をすべての画面に含めることです。この概念はフラグメントと呼ばれます。フラグメントのコードを一度変更すると、他のすべての画面に反映されます。 ここにフラグメントのチュートリアルがあります。

于 2012-07-16T20:14:12.443 に答える