2

私はAndroidの初心者なので、これがお粗末な質問である場合はご容赦ください。
画面の上部にメニューを配置しようとしていますが、アプリケーション内のすべてのアクティビティにメニューを含める必要があります。
今私の質問は、この目標をどのように達成できるかということです。XMLを作成してどこにでも含める必要がありますか、それとも基本アクティビティを持ち、その中に他のアクティビティをホストする必要がありますか?

更新:下のスクリーンショットを見てください、私はまったく同じものが欲しいです。2セットのボタンが上にあり、もう1つが下にあることに気付いた場合。中央の画面はスクロール可能です。 アプリのスクリーンショット

4

2 に答える 2

3

Androidトップメニューのようなものは存在しません。CommonsWareから引用

WindowsウィンドウやOSX画面の上部にあるバーのようなものを参照していると仮定すると、Androidには「トップバーメニュー」はありません。独自の何かを作成することは大歓迎ですが、そのような概念に対する組み込みのプラットフォームサポートはありません。

既存のAndroidアプリケーションで時間を費やすと、「上部に固定された表示メニュー」を実装しているものはほとんどありません。そうするものを見つけたら、実際に動作しているスクリーンショットをいくつか投稿してください。おそらく、それを実装する方法についていくつかの提案をすることができます。

したがって、更新後は、actionBarの実装について何かを知る必要があります。だからこれらのリンクを見てください

actionbarsherlockjohannilsson / android-actionbarcyrilmottier / GreenDroid

そして、Buttons下に追加するには、を使用する必要があります<RelativeLayout>、にマージンを追加しますButtons

下部のボタンは、このように設定できます

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#3B3B3B"
    >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="10dp"
        android:gravity="center_horizontal"
        android:layout_alignParentBottom="true"
        >

        <Button 
            android:id="@+id/loginBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:text="Second"
            />

        <Button 
            android:id="@+id/loginBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:text="Second"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="67dp"
        android:gravity="center_horizontal"
        android:orientation="horizontal"
        android:padding="10dp" >

        <Button
            android:id="@+id/loginBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:text="Second" />

        <Button
            android:id="@+id/loginBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:text="Second" />
    </LinearLayout>
</RelativeLayout>
于 2012-06-10T09:52:35.213 に答える
1

私は通常、下部と上部のツールバーを個別のレイアウト xml ファイルとして作成し、必要なアクティビティに含めます。また、両方のツールバーを処理できる基本アクティビティも作成します。利用可能な場合は、上部のツールバーをプログラムでアクションバーに配置できます。

于 2012-06-10T10:33:03.717 に答える