views:

43

answers:

1

I'm currently having trouble with a SlidingDrawer. I want it to be closed when the application starts so it doesn't get in the way. However, it is determined that it will be open, despite putting slide.close() in the onCreate() of my activity. It seems to be closed if i use slide.animateClose() instead, but this slows my application down loads.

How do I make it closed by default?

Cheers

    <SlidingDrawer 
    android:layout_width="fill_parent" 
    android:padding="4dp" 
    android:id="@+id/Mnu_Slide" 
    android:content="@+id/Mnu_SlideCont" 
    android:handle="@+id/Mnu_SlideBtn" 
    android:layout_gravity="bottom" 
    android:layout_height="112dp">
    <ImageView 
        android:id="@id/Mnu_SlideBtn" 
        android:src="@drawable/handle1" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" />
    <LinearLayout 
        android:id="@id/Mnu_SlideCont" 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent" 
        android:orientation="horizontal" 
        android:gravity="center_vertical|center_horizontal" android:background="@drawable/tray1xml">
            <ImageView 
                android:id="@+id/Mnu_Chem" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
                android:src="@drawable/icon" />
            <ImageView 
                android:id="@+id/Mnu_Physics" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
                android:src="@drawable/physicon" />
    </LinearLayout> 
</SlidingDrawer>
A: 

I can't see anything obviously wrong with that. It looks very similar to my own SlidingDrawer code (which I've included in this question) and that always starts closed, with no need to close it explicitly in the onCreate() method.

I suspect it might have something to do with whatever this view is lodged inside: is it by any chance in a LinearLayout? Try changing it to a RelativeLayout instead. The docs for SlidingDrawer are a bit vague but they do say:

SlidingDrawer should be used as an overlay inside layouts. This means SlidingDrawer should only be used inside of a FrameLayout or a RelativeLayout for instance.

Hope that helps.

Mark