Android SlidingDrawer (DEPRECATED) - Androhub

Sliding Drawer

Android SlidingDrawer (DEPRECATED)

SlidingDrawer represents a widget, where we can use in our Android applications. SlidingDrawer has the ability to hide and/or appear content when the user drags a handle. More specifically, it includes two basic views:

  • the handle where the user can drag.
  • the hidden content that is associated with the handle and it is shown up when the user drags the handle.

It is very important to mention that the SlidingDrawer class is deprecated in Android Api 17 and above, so it is recommended to use it in previous versions or make your own widget in the new ones.

Example

In this example I will show you how to implement Sliding Drawer.

VIDEO DEMO

Let’s get start by creating a project in Eclipse IDE.

1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. (I kept my main activity name as MainActivity.java).

2.  Create a layout file for MainActivtiy.java under res ⇒ layout folder. I named the layout file as activity_main.xml. In this layout i had taken one SlidingDrawer and inside it there is one Button for Handler and there is LinearLayout for Content that will be hidden and showed when handler button pressed or sliding drawer slided.

3. For buttons background drawable we have to make a drawable xml file for button selector in drawable directory naming button_selector.xml. 

4. Now, come to MainActivity.java and add the following code. In this class i had just done how to show/hide sliding drawer and implement clicklisteners on button clicks.

5. Now, run the app and you will get the output as shown in video.

Thanks. :)

 

Post comment

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