Android - Making Sliding Drawer to slide from Left-to-Right

后端 未结 5 1067
春和景丽
春和景丽 2020-11-28 11:49

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



        
相关标签:
5条回答
  • 2020-11-28 11:49

    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>
    
    0 讨论(0)
  • 2020-11-28 12:02

    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/

    0 讨论(0)
  • 2020-11-28 12:06

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

    0 讨论(0)
  • 2020-11-28 12:06

    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

    0 讨论(0)
  • 2020-11-28 12:13

    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

    0 讨论(0)
提交回复
热议问题