2

I have used android:rotation="180" to make the sliding drawer horizontal to appear on left of screen. It works fine. But, the contents appears upside down in it because of the rotation. I tried to rotate the content layout also, but it gets rotated only after the sliding drawer is completely open. Please check my code attached with this.

MainActivity.java

public class MainActivity extends Activity {

ArrayAdapter<String> myAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ListView LV = (ListView) findViewById(R.id.listView1);

    String [] List =  {"item 1","item 2","item 3","item 4"};
    myAdapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.textView1, List);
    LV.setAdapter(myAdapter);

    }

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center" >

<SlidingDrawer
    android:id="@+id/slidingDrawer1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:content="@+id/listView1"
    android:handle="@+id/handle"
    android:orientation="horizontal"
    android:rotation="180" >

<Button
    android:id="@+id/handle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Handle" />

 <ListView
     android:id="@+id/listView1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:rotation="180"
     tools:listitem="@layout/list_item" >
  </ListView>

</SlidingDrawer>

list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_launcher" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:padding="10dp"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>
SubbaReddy PolamReddy
  • 2,083
  • 2
  • 17
  • 23
SKK
  • 5,261
  • 3
  • 27
  • 39
  • This may help: http://stackoverflow.com/questions/3793194/android-making-sliding-drawer-to-slide-from-left-to-right – Jimbali Oct 16 '12 at 12:10

3 Answers3

3

I've implemented a complete replacement for the SlidingDrawer component and it works from any side/direction. see http://www.github.com/kedzie/DraggableDrawers for details.

Now available from Maven Central ( maven-android-plugin ):

<dependency>
  <groupid>com.github.kedzie.draggabledrawers</groupId>
  <artifactId>library</artifactId>
  <version>1.0.0</version>
  <type>apklib</type>
</dependency>
mark.kedzierski
  • 663
  • 4
  • 10
  • Nice library.Thanks. I would try this out to check if this will work when the drawerlayouts are on top of one another and handles are one below the other. – SKK Jul 12 '13 at 06:03
  • 1
    FOr the record a single DragLayout can hold multiple drawers. But stacking should work just fine as touch events are only intercepted if you are actually dragging a drawer. Also FYI I've added edge dragging functionality.. checkout the latest on the website http://kedzie.github.io/DraggableDrawers. – mark.kedzierski Jul 25 '13 at 20:55
  • @mark.kedzierski i cant find your sliding drawer code. Where is it ? The link isn't valid anymore. – Sheraz Ahmad Khilji May 21 '15 at 12:42
1

Please take a look at THIS tutorial. You don't need to rotate the drawer...

Sebastian Breit
  • 6,137
  • 1
  • 35
  • 53
  • I have seen that link before. But that is not a sliding drawer. It just hides / pops a particular transparent layout. And that can not serve me with the sliding effect. – SKK Oct 16 '12 at 12:14
  • You can add the slider effect too by passing an Animation! – Sebastian Breit Oct 16 '12 at 12:16
  • oh. okay. Thanks. But, That seems a bit cumbersome for a beginner :( All I want to do is show a list of strings inside that. I will give it a try. – SKK Oct 16 '12 at 12:26
-2

Try to use android:gravity="left" instead of rotation

Tamir Scherzer
  • 995
  • 8
  • 8
  • Where do you want me to use the above statement? sorry, but I don't think it works for me. – SKK Oct 16 '12 at 12:19