How to make an Android SlidingDrawer slide out from the left?

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.
You can similarly make a SlidingDrawer that descends from the top, like I did here.

Look at my examples here, first from right to left, to be able to see the differences.

<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="horizontal"
    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="https://stackoverflow.com/questions/1137350/@drawable/ic_launcher" />
    <ImageView android:id="@+id/content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:src="https://stackoverflow.com/questions/1137350/@drawable/ic_launcher" />
</SlidingDrawer>

Now look what I changed to make it sliding out from the left.

<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="horizontal"
    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="https://stackoverflow.com/questions/1137350/@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="https://stackoverflow.com/questions/1137350/@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.

Leave a Comment