Sliding drawer example in android left to right tutorial

Create sliding drawer slide out from left to right in android application.

Sliding drawer can be easily pulled out to left to right position using rotation attribute.Left to right sliding drawer is mainly used to developer simple sliding layout, menus applications with swipe in out effect. So here is the complete step by step tutorial for Sliding drawer example in android left to right tutorial.

android-project-download-code-button

There are two images used in this project first one is arrow_icon.png & second is slidingdrawer_image.png sample drawer body image. Download these images and put them into your res-> drawable-hdpi folder.

drawable hdpi folder

Images:

arrow_icon

SlidingDrawer_image

Sliding drawer example in android left to right tutorial.

Code for MainActivity.java file.

package com.slidingdrawerleft2right_android_examples.com;
import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

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

Code for activity_main.xml layout file.

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 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="wrap_content"
 android:layout_height="wrap_content"
 android:src="@drawable/arrow_icon"
 android:rotation="270"
 />

 <LinearLayout
 android:id="@id/content"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:rotation="180"
 android:orientation="horizontal">
 
<!-- DEFINE ALL YOUR CONTENT,WIDGETS HERE WHICH YOU WANT TO ADD IN SLIDING DRAWER LAYOUT. -->
 
 <ImageView
 android:id="@+id/imageView1"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:src="@drawable/slidingdrawer_image" />
 
 <!-- DEFINE ALL YOUR CONTENT WIDGETS HERE WHICH YOU WANT TO ADD IN SLIDING DRAWER LAYOUT. -->
 
 </LinearLayout>
 </SlidingDrawer>
</LinearLayout>

Screenshots :

SlidingDrawer1

Sliding drawer example in android left to right tutorial

Click Here To Download Sliding drawer example in android left to right tutorial project.

Leave a Reply

Your email address will not be published. Required fields are marked *