2

I've looked in many places, but I cant find a decent tutorial on how to make a SlidingDrawer for my application.

Say i already have an XML file, and i want to add a sliding drawer to it..i also want to add a textview and listview object, and some buttons in it...how would i go about doing that?

Any help will be greatly appreciated!

somanys21
  • 107
  • 2
  • 6

1 Answers1

3

Here is a SlidingDrawer sample app. In particular, here is the layout:

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

Now, in this case, the whole activity is just a SlidingDrawer. That's relatively unusual -- this sample is short because it is from a book.

More commonly, I would expect you to put a SlidingDrawer as a child of a RelativeLayout, so you can have other children of the RelativeLayout and have the drawer slide over top of them when opened. I believe you will need the SlidingDrawer to be the last child of the RelativeLayout in this case.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491