2

私は多くの場所を調べましたが、アプリケーション用のSlidingDrawerを作成する方法についての適切なチュートリアルを見つけることができません。

すでにXMLファイルがあり、それにスライドドロワーを追加したいとします。また、textviewオブジェクトとlistviewオブジェクト、およびその中にいくつかのボタンを追加したいのですが、どうすればよいでしょうか。

どんな助けでも大歓迎です!

4

1 に答える 1

3

これがSlidingDrawerサンプルアプリです。特に、レイアウトは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FF4444CC"
        >
    <SlidingDrawer
        android:id="@+id/drawer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:handle="@+id/handle"
        android:content="@+id/content">
        <ImageView
            android:id="@id/handle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/tray_handle_normal"
        />
        <Button
            android:id="@id/content"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="I'm in here!"
        />
    </SlidingDrawer>
</FrameLayout>

さて、この場合、アクティビティ全体は単なるSlidingDrawer. これは比較的珍しいことです。このサンプルは本からのものなので短いです。

SlidingDrawerより一般的には、を の子として配置することを期待しますRelativeLayout。これにより、 の他の子をRelativeLayout作成し、開いたときに引き出しをその上にスライドさせることができます。SlidingDrawerこの場合、 を の最後の子にする必要があると思いますRelativeLayout

于 2010-11-01T20:05:33.700 に答える