Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SlidingDrawer from top?

Tags:

android

Is there any way to make the drawer slide from top to bottom?

like image 235
stefos Avatar asked Sep 12 '10 17:09

stefos


2 Answers

I've found a simple way to do that. All you have to do is to set the rotation of 180º for the slidingDrawer, the content and the handle. It's easier to understand with an example, so look what I've done:

First, I'll show you my old SlidingDrawer, from bottom to top.

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/slidingDrawer"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:orientation="vertical"     android:gravity="center_horizontal"     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/ic_launcher" />     <ImageView android:id="@+id/content"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:background="#FF0000"         android:src="@drawable/ic_launcher" /> </SlidingDrawer> 

Now look at the changes I made, setting the rotation of 180º

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/slidingDrawer"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:orientation="vertical"     android:gravity="center_horizontal"     android:handle="@+id/handle"     android:content="@+id/content"     android:rotation="180">     <LinearLayout android:id="@+id/handle"         android:layout_width="wrap_content"         android:layout_height="wrap_content">         <ImageView android:id="@+id/imageView"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/ic_launcher"             android:rotation="180" />     </LinearLayout>     <ImageView android:id="@+id/content"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:background="#FF0000"         android:src="@drawable/ic_launcher"         android:rotation="180" /> </SlidingDrawer> 

Note that I also created a LinearLayout to set as handle, and didn't change it's rotation, but I changed the rotation of it's child. This was to prevent a small issue I had, but everything is working fine and it's simple.

like image 58
Leandroid Avatar answered Oct 03 '22 05:10

Leandroid


The default SlidingDrawer class doesn't allow this. You can use the Panel class from here to get something very similar though: http://code.google.com/p/android-misc-widgets/

http://www.ohloh.net/p/android-misc-widgets

like image 44
Computerish Avatar answered Oct 03 '22 07:10

Computerish