2010-11-01 83 views
2

我看了很多地方,但我找不到一個像樣的教程,如何爲我的應用程序製作一個SlidingDrawer。Android SlidingDrawer how-to

說我已經有一個XML文件,我想添加一個滑動抽屜給它..我也想添加一個textview和listview對象,並在它的一些按鈕...我會怎麼做?

任何幫助將不勝感激!

回答

3

這是SlidingDrawer sample app。特別是,這裏的佈局:

<?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。這是相當不尋常的 - 這個例子很簡短,因爲它來自一本書。

更常見的情況是,我希望您將作爲RelativeLayout的孩子,因此您可以讓RelativeLayout的其他孩子在打開時將其抽屜滑過頂部。我相信在這種情況下,您需要SlidingDrawer成爲RelativeLayout的最後一個孩子。

+0

非常感謝!我會給這個鏡頭。 – somanys21 2010-11-01 20:42:42