14

I have implemented "Sliding Drawer" in my application using the below XML layout: (I got this example from androidpeople.com)

<LinearLayout android:id="@+id/LinearLayout01"
 android:layout_width="fill_parent" android:layout_height="fill_parent"
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:background="@drawable/androidpeople">

 <SlidingDrawer 
  android:layout_width="wrap_content" 
  android:id="@+id/SlidingDrawer" 
  android:handle="@+id/slideHandleButton" 
  android:content="@+id/contentLayout" 
  android:layout_height="75dip"
  android:orientation="horizontal">

  <Button 
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content" 
   android:id="@+id/slideHandleButton" 
   android:background="@drawable/closearrow">
  </Button>

  <LinearLayout 
   android:layout_width="wrap_content" 
   android:id="@+id/contentLayout" 
   android:orientation="horizontal" 
   android:gravity="center|top" 
   android:padding="10dip" 
   android:background="#C0C0C0" 
   android:layout_height="wrap_content">


   <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Content"></Button>
   <Button android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Content"></Button>
   <Button android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Content"></Button>

  </LinearLayout>

 </SlidingDrawer>
</LinearLayout>

but what I am wanting is to Slide the drawer from Left-to-right(Horizontal) instead of this right-to-left, how do i make slide drawer to slide from left-to-right direction?

Please share your idea/view/opinion/issue with me and catch me out of this problem.

Ali Khaki
  • 1,184
  • 1
  • 13
  • 24
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • i have gone through this tutorial on link http://blog.sptechnolab.com/2011/02/10/android/android-sliding-drawer/ and its really works. I hope you will like the post. – user609239 Feb 16 '11 at 07:01

5 Answers5

7

Here is a tutorial on this: link

It seems that there is no positioning for sliding drawer, I can not find any layout attributes provided by the sdk. But like in the tutorial above you could write your own sliding drawer widget and apply layout attributes to position the slider/panel.


You can checkout https://github.com/umano/AndroidSlidingUpPanel

DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
  • 2
    i already checked out that link , in which i havent found any project/code on that link given in the answer and also i doesn't found anything about "Horizontal slider" – Paresh Mayani Sep 25 '10 at 09:31
  • did you solve your problem? writing your own class, maybe extend sliding drawer, would solve it – DarkLeafyGreen Sep 26 '10 at 09:00
  • I believe that's not supported unless you extend the widget – Mina Wissa Sep 26 '10 at 11:42
  • thanx, but i dont know how do i do it ? pls share your knowledge regarding extending and sliding from left-to-right by updating your current answer, please – Paresh Mayani Sep 27 '10 at 04:41
  • Try adding the main contents of answer here instead of just relying on links as they can go dead and you cannot attach a listener to their life. – Shubham A. Nov 10 '15 at 17:26
6

You can use this for left to right drawer ..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView 
android:layout_width="50dip"
android:layout_height="50dip"
android:text="@string/hello"
/>
<SlidingDrawer
 android:id="@+id/drawer"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal"
 android:handle="@+id/handle"     
 android:content="@+id/content">


<ImageView
 android:id="@id/handle"
 android:layout_width="50dip"
 android:layout_height="50dip"  
 android:src="@drawable/icon"
/>

<LinearLayout
 android:id="@id/content"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical">
<Button
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:text="Big Big Button"/>
</LinearLayout>

</SlidingDrawer>
</LinearLayout>
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
Girish R
  • 69
  • 1
  • 1
5

The best and easy solution is adding one line of code to SlidingDrawer, android:rotation = "180" for more info please refer to this link.

Community
  • 1
  • 1
Hesam
  • 52,260
  • 74
  • 224
  • 365
4

The best answer is to use this component that sephiroth wrote based upon the original SlidingDrawer: http://blog.sephiroth.it/2011/03/29/widget-slidingdrawer-top-to-bottom/

user123321
  • 12,593
  • 11
  • 52
  • 63
2

I used Girish R's answer and just rotated it.... Works like a charm Also, I used a frame layout to ensure it open properly....

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <SlidingDrawer
        android:id="@+id/drawer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:handle="@+id/handle"
        android:rotation="180"
        android:content="@+id/content">


        <ImageView
            android:id="@id/handle"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:src="@drawable/ic_launcher"
            android:rotation="180"
            />

        <LinearLayout
            android:id="@id/content"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:rotation="180">
            <Button
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="Big Big Button"/>
        </LinearLayout>
    </SlidingDrawer>
    <TextView
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:text="HELLO WORLD"
        />

</FrameLayout>

SlidingDrawer from left to right

130nk3r5
  • 1,120
  • 10
  • 12