0

I am trying to use a SlidingDrawer which has a bottom to top structure.. I have placed 4 spinners inside the content of that sliding drawer.. And when i executes, the handle(which i have an image) is showing above the screen. I want that handle just above the content(ie just above the 4 spinners..)

here is my xml layouts...

main.xml

<?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:orientation="vertical">
    <SlidingDrawer
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/drawer"
        android:handle="@+id/MyHandle"
        android:content="@+id/MyContent">
            <LinearLayout 
                android:id="@+id/MyHandle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="bottom"
                android:orientation="vertical">
                <ImageView 
                    android:id="@+id/SlideIcon"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:src="@drawable/images"/>
            </LinearLayout>
            <FrameLayout 
                android:id="@+id/MyContent"
                android:layout_width="fill_parent"
                android:layout_height="200dip"
                android:orientation="vertical">
                <include
                    android:id="@+id/DrawerContent"
                    layout="@layout/spinnerlayout" 
                    android:layout_height="wrap_content"/>
            </FrameLayout>
    </SlidingDrawer>
</FrameLayout>

and spinnerlayout.xml..

<?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="wrap_content"
    android:foregroundGravity="bottom"
    android:layout_gravity="bottom"
    android:background="@color/grey">

    <LinearLayout 
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="vertical">
        <Spinner 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/spinner_first"/>
        <Spinner 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/spinner_second"/>
        <Spinner 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/spinner_third"/>
        <Spinner 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/spinner_fourth"/>
    </LinearLayout>
</FrameLayout>

And to make my question more clear, i have the screenshots..

before handle is clicked

after handle is clicked

I want to have that handle(arrow) just above that spinners..

Is it possible to place it?

Dil Se...
  • 877
  • 4
  • 16
  • 43

1 Answers1

3

The onMeasure() method of the SlidingDrawer class basically overrides the layout modes to fill_parent, this is why layout_height="wrap_content" is not working.

To get around this, you can extend SlidingDrawer with a re-implemented onMeasure() method that honors the layout_width and layout_height attributes. You can then use this custom class in your XML layout by replacing with .

Note that since the drawer will no longer be filling the parent layout, you will have to enclose it in a LinearLayout with the gravity attribute set to the edge where the drawer should be.

the Answer
your Question

Community
  • 1
  • 1
Parag Chauhan
  • 35,760
  • 13
  • 86
  • 95
  • I know it dear, through overriding onMeasure() i can set it.. And there are lots of examples too. But i had asked this question to know whether it is possible to set the height.. what is ur opinoin sir, is it possible? – Dil Se... Jan 25 '12 at 10:09
  • And this is Another Sample For u http://android-journey.blogspot.com/2009/12/android-viewflipper-and-slidingdrawer.html – Parag Chauhan Jan 26 '12 at 10:31