{"id":1634,"date":"2016-04-29T07:58:26","date_gmt":"2016-04-29T07:58:26","guid":{"rendered":"http:\/\/abhiandroid.com\/ui\/?page_id=1634"},"modified":"2019-06-12T10:37:52","modified_gmt":"2019-06-12T10:37:52","slug":"slidingdrawer","status":"publish","type":"page","link":"https:\/\/abhiandroid.com\/ui\/slidingdrawer","title":{"rendered":"Sliding Drawer Tutorial With Example In Android Studio"},"content":{"rendered":"<p>In Android, Sliding Drawer is used to hide the content out of the screen and allows the user to drag a handle to bring the content on screen. It can be used horizontally or vertically both.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1642\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/Sliding-Drawer-in-Android.jpg\" alt=\"Sliding Drawer in Android\" width=\"480\" height=\"348\" srcset=\"https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/04\/Sliding-Drawer-in-Android.jpg 480w, https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/04\/Sliding-Drawer-in-Android-300x218.jpg 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/p>\n<p>Sliding Drawer is a\u00a0special widget composed of two children views, one is the handle that the user\u2019s drags, and other is content attached to the handle which\u00a0dragged along-with it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1643\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/Sliding-Drawer-handle-content.jpg\" alt=\"Sliding Drawer handle content\" width=\"340\" height=\"364\" srcset=\"https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/04\/Sliding-Drawer-handle-content.jpg 340w, https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/04\/Sliding-Drawer-handle-content-280x300.jpg 280w\" sizes=\"auto, (max-width: 340px) 100vw, 340px\" \/><\/p>\n<hr \/>\n<h4><strong>Sliding Drawer Important Points:<\/strong><\/h4>\n<ul>\n<li>Sliding Drawer should be used as an overlay inside layouts means Sliding Drawer should only be used inside of a Relative Layout or a Frame Layout for instance.<\/li>\n<li>The size of the Sliding Drawer defines how much space the content will occupy once slide out, so Sliding Drawer should usually use match_parent for both its dimensions.<\/li>\n<li>Inside an XML ( layout ), Sliding Drawer must define the id of the handle and of the content.<\/li>\n<\/ul>\n<hr \/>\n<h4><strong>Basic\u00a0<\/strong><strong>Sliding Drawer XML Code<\/strong><strong>:<\/strong><\/h4>\n<pre>&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:id=\"@+id\/layout\"\r\n    android:layout_width=\"fill_parent\"\r\n    android:layout_height=\"fill_parent\"&gt;\r\n\r\n    &lt;SlidingDrawer\r\n        android:id=\"@+id\/simpleSlidingDrawer\"\r\n        android:layout_width=\"fill_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:content=\"@+id\/content\"\r\n        android:handle=\"@+id\/handle\"\r\n        android:orientation=\"horizontal\"\r\n        android:rotation=\"180\"&gt;\r\n\r\n        &lt;!-- Button for the handle of SlidingDrawer --&gt;\r\n        &lt;Button\r\n            android:id=\"@id\/handle\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:background=\"#0f0\"\r\n            android:rotation=\"270\"\r\n            android:text=\"Open\"\r\n            android:textColor=\"#fff\" \/&gt;\r\n\r\n        &lt;!-- layout for the content of the SLidingDrawer --&gt;\r\n        &lt;LinearLayout\r\n            android:id=\"@id\/content\"\r\n            android:layout_width=\"fill_parent\"\r\n            android:layout_height=\"fill_parent\"\r\n            android:orientation=\"horizontal\"\r\n            android:rotation=\"180\"&gt;\r\n\r\n          &lt;!-- DEFINE ALL YOUR CONTENT,WIDGETS HERE WHICH YOU WANT TO ADD IN SLIDING DRAWER LAYOUT. --&gt;\r\n            &lt;ListView\r\n                android:id=\"@+id\/simpleListView\"\r\n                android:layout_width=\"fill_parent\"\r\n                android:layout_height=\"fill_parent\" \/&gt;\r\n        &lt;\/LinearLayout&gt;\r\n    &lt;\/SlidingDrawer&gt;\r\n&lt;\/LinearLayout&gt;<\/pre>\n<hr \/>\n<h4><strong>Important Methods Of Slider Drawer:<\/strong><\/h4>\n<p>Let\u2019s we discuss some important methods of SliderLayout that may be called in order to manage the SliderDrawer.<\/p>\n<p><span style=\"color: #008000;\"><strong>1. open():<\/strong><\/span> This method is used to opens the drawer immediately. Sometime we open the drawer on View click (Button, TextView etc), so for that functionality we need to use this function.<\/p>\n<p>Below we show how to use the open method of Sliding Drawer. We can also use this method on click of a View(Button or any other view).<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer =(SlidingDrawer) findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nsimpleSlidingDrawer.open(); \/\/ open the Sliding Drawer\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>2. close():<\/strong><\/span> This method is used to close the drawer immediately. Sometime we close the drawer on View click ( Button, TextView etc), so for that we need to use this function.<\/p>\n<p>Below we show how to use the close method of Sliding Drawer. We can also use this method on click of a View(Button or any other view).<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer =(SlidingDrawer)findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nsimpleSlidingDrawer.close(); \/\/ close the Sliding Drawer\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>3. animateOpen():<\/strong><\/span> This method is used to opens the drawer with an animation. This method is same as simple open() method but the only difference is we use this method when we need to open the drawer with an animation.<\/p>\n<p>Below we open the drawer with an animation. We can also use this method on click of a View (Button or any other view).<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer =(SlidingDrawer)findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nsimpleSlidingDrawer.animateOpen(); \/\/ open the Sliding Drawer with an animation\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>4. animateClose():<\/strong><\/span> This method is used to close the drawer with an animation. This method is same as simple close() method but the only difference is we use this method when we need to close the drawer with an animation.<\/p>\n<p>Below we close the drawer with an animation. We can also use this method on click of a View (Button or any other view).<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer =(SlidingDrawer)findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nsimpleSlidingDrawer.animateOpen(); \/\/ close the Sliding Drawer with an animation\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>5. isOpened():<\/strong><\/span> This method indicate whether the drawer is currently fully opened. This method returns Boolean type value either\u00a0true or false. It returns true if the drawer is currently opened and false if it is close.<\/p>\n<p>Below we check whether the drawer is currently opened or not.<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer =(SlidingDrawer)findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nBoolean isSliderOpen= simpleSlidingDrawer.isOpened(); \/\/ check whether the slider is opened or not\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>6. lock():<\/strong><\/span> This method is used to lock the SliderDrawer so that touch events are ignores. Sometime in a situation we need to lock the drawer so that touch event are disable\u00a0and here\u00a0we use this method.<\/p>\n<p>Below we lock the drawer so that touch event are ignores. We can also use this method on click of a View (Button or any other view).<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer = (SlidingDrawer) findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nsimpleSlidingDrawer.lock(); \/\/ lock the sliderDrawer so that touch event are disabled\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>7. unlock():<\/strong><\/span> This method is used to unlock the SlidingDrawer so that touch events are processed. This method is used when for a situation we lock the drawer and now we need to unlock the drawer so that touch events are processed.<\/p>\n<p>Below we unlock the drawer so that touch event are processed. We can also use this method on click of a View (Button or any other view).<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer = (SlidingDrawer) findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nsimpleSlidingDrawer. unlock(); \/\/ unlock the sliderDrawer so that touch event are processed\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>8. setOnDrawerCloseListener(OnDrawerCloseListeneronDrawerCloseListener):<\/strong>\u00a0\u00a0<\/span>This method is used to sets the listener that receives the notification when the drawer becomes close.<\/p>\n<p>Below we show how to use of setOnDrawerCloseListener event in android.<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer = (SlidingDrawer) findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nsimpleSlidingDrawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {\r\n@Override\r\npublic void onDrawerClosed() {\r\n\/\/ add code here for the drawer closed event\r\n}\r\n});\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>9. setOnDrawerOpenListener(OnDrawerOpenListeneronDrawerOpenListener):<\/strong> <\/span>This method is used to set the listener that receives<strong>\u00a0<\/strong>the notification when the drawer becomes open.<\/p>\n<p>Below we show how to use setOnDrawerOpenListener() event in android.<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer = (SlidingDrawer) findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nsimpleSlidingDrawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {\r\n@Override\r\npublic void onDrawerOpened() {\r\n\/\/ add code here for the Drawer Opened Event\r\n}\r\n});\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>10. setOnDrawerScrollListener(OnDrawerScrollListeneronDrawerScrollListener):<\/strong> <\/span>This method is used to set the listener that receives<strong>\u00a0<\/strong>the notification when the drawer start or ends a scroll.<\/p>\n<p>Below we show how to use of setOnDrawerScrollListener event in android.<\/p>\n<pre>SlidingDrawer simpleSlidingDrawer = (SlidingDrawer) findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\nsimpleSlidingDrawer.setOnDrawerScrollListener(new SlidingDrawer.OnDrawerScrollListener() {\r\n@Override\r\npublic void onScrollStarted() {\r\n\/\/ add code here for the scroll started.\r\n}\r\n\r\n@Override\r\npublic void onScrollEnded() {\r\n\/\/ add code here for the scroll ended.\r\n}\r\n});\r\n<\/pre>\n<hr \/>\n<h4><strong>Attributes of SliderDrawer:<\/strong><\/h4>\n<p>Now let\u2019s we discuss some common attributes of a SliderDrawer that helps us to configure it in our layout (xml).<\/p>\n<p><span style=\"color: #008000;\"><strong>1. Id:\u00a0<\/strong><\/span>id attribute is used to uniquely identify a SliderDrawer.<\/p>\n<pre>&lt;SlidingDrawer\r\n\r\n    android:id=\"@+id\/drawer\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:handle=\"@+id\/handle\"\r\n    android:content=\"@+id\/content\"&gt;\r\n\r\n    &lt;!--Define Views Here--&gt;\r\n\r\n&lt;\/SlidingDrawer&gt;<\/pre>\n<p><span style=\"color: #008000;\"><strong>2. handle:<\/strong> <\/span>This attribute is used as an Identifier for the child that represents the drawer&#8217;s handle.\u00a0This is the one contains handler button that is always visible in the application.<\/p>\n<p>Below we create a button for handle the content and use the id of the button in the handle attribute of SlidingDrawer.<\/p>\n<pre>&lt;SlidingDrawer\r\n    android:id=\"@+id\/drawer\"\r\n    android:layout_width=\"fill_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    android:content=\"@+id\/content\"\r\n    android:orientation=\"horizontal\"\r\n    android:rotation=\"180\"\r\n    android:handle=\"@+id\/handleImageView\"&gt; &lt;!-- set the Id of the handle (ImageView) --&gt;\r\n\r\n    &lt;!-- create  a ImageView for handle the content of DrawerLayout --&gt;\r\n    &lt;ImageView\r\n        android:id=\"@id\/handleImageView\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:rotation=\"270\"\r\n        android:src=\"@drawable\/ic_launcher\" \/&gt;\r\n    \r\n&lt;!-- layout for the content of the SLidingDrawer --&gt;\r\n    &lt;LinearLayout\r\n        android:id=\"@id\/content\"\r\n        android:layout_width=\"fill_parent\"\r\n        android:layout_height=\"fill_parent\"\r\n        android:orientation=\"horizontal\"\r\n        android:rotation=\"180\"&gt;\r\n        &lt;!-- DEFINE ALL YOUR CONTENT,WIDGETS HERE WHICH YOU WANT TO ADD IN SLIDING DRAWER LAYOUT. --&gt;\r\n        \r\n    &lt;\/LinearLayout&gt;\r\n&lt;\/SlidingDrawer&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1645\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/handle-sliding-drawer-Android.jpg\" alt=\"handle sliding drawer Android\" width=\"243\" height=\"273\" \/><\/p>\n<p><span style=\"color: #008000;\"><strong>3. content:<\/strong> <\/span>This attribute is used as an Identifier for the child that represents the drawer&#8217;s content.\u00a0On click of handle the content become visible.<\/p>\n<p>In the above code we also used content as an identifier for the child which show content on screen.<\/p>\n<p><span style=\"color: #008000;\"><strong>4. orientation: <\/strong><\/span>The orientation attribute is used to set the child horizontally or vertically. In SliderDrawer default orientation is vertical.<\/p>\n<p><strong><span style=\"color: #008000;\">5. rotation:\u00a0<\/span><\/strong><span style=\"color: #008000;\"><span style=\"color: #000000;\">This attribute is used to rotate the view in degrees. We set rotate value in degrees to rotate the view in different directions.<\/span><\/span><\/p>\n<p>In the above code\u00a0we also used also horizontal orientation and 180 degree rotation for the SliderDrawer.<\/p>\n<hr \/>\n<h4><strong><span style=\"line-height: 1.6471;\">Sliding Drawer Example In Android Studio:<\/span><\/strong><\/h4>\n<p><span style=\"line-height: 1.6471;\">Below is the example of Sliding Drawer in which we display a SlidingDrawer by using its different attributes. In this we use one Button for the handle of SlidingDrawer and a ListView for displaying the content of the SlidingDrawer.<\/span><\/p>\n<p>Firstly we create String <a href=\"\/java\/arrays\">array<\/a> and then ArrayAdapter is used to fill the data in the list. In this we also implement setOnDrawerOpenListener and setOnDrawerCloseListener events for changing the text of handle button.<\/p>\n<p>Below you can download complete Android Studio project code, see final output and step by step explantion of the example:<\/p>\n<p style=\"text-align: center;\"><a class=\"download\" href=\"https:\/\/github.com\/abhisheksaini4\/SliderDrawerExample\" target=\"_blank\">Download Code<\/a><a class=\"help\" title=\"Learn How To Download Code And Import In Android Studio\" href=\"\/androidstudio\/download-code-abhiandroid\" target=\"_blank\" rel=\"nofollow\"> ? <\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1648\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/Sliding-Drawer-Example-In-Android-Studio.gif\" alt=\"Sliding Drawer Example In Android Studio\" width=\"300\" height=\"444\" \/><\/p>\n<p><span style=\"color: #008000;\"><strong>Step 1<\/strong><strong>:\u00a0<\/strong><\/span>Create a new project and name it SlidingDrawerExample<\/p>\n<p><span style=\"color: #008000;\"><strong>Step 2:<\/strong><\/span><strong>\u00a0<\/strong>Open <strong>res -&gt; layout -&gt; activity_main.xml (or) main.xml<\/strong> and add following code:<\/p>\n<p>In this step we open an xml file and add the code for displaying a SlidingDrawer by using its different attributes. In this we display one Button for the handle of SlidingDrawer and a ListView for the content of the SlidingDrawer.<\/p>\n<pre>&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\nandroid:id=\"@+id\/layout\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"fill_parent\"&gt;\r\n\r\n&lt;SlidingDrawer\r\nandroid:id=\"@+id\/simpleSlidingDrawer\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:content=\"@+id\/content\"\r\nandroid:handle=\"@+id\/handle\"\r\nandroid:orientation=\"horizontal\"\r\nandroid:rotation=\"180\"&gt;\r\n&lt;!-- Button for the handle of SlidingDrawer --&gt;\r\n&lt;Button\r\nandroid:id=\"@id\/handle\"\r\nandroid:layout_width=\"wrap_content\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:background=\"#0f0\"\r\nandroid:rotation=\"270\"\r\nandroid:text=\"Open\"\r\nandroid:textColor=\"#fff\" \/&gt;\r\n&lt;!-- layout for the content of the SLidingDrawer --&gt;\r\n&lt;LinearLayout\r\nandroid:id=\"@id\/content\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"fill_parent\"\r\nandroid:orientation=\"horizontal\"\r\nandroid:rotation=\"180\"&gt;\r\n&lt;!-- DEFINE ALL YOUR CONTENT,WIDGETS HERE WHICH YOU WANT TO ADD IN SLIDING DRAWER LAYOUT. --&gt;\r\n&lt;ListView\r\nandroid:id=\"@+id\/simpleListView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"fill_parent\" \/&gt;\r\n&lt;\/LinearLayout&gt;\r\n&lt;\/SlidingDrawer&gt;\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>Step 3:<\/strong>\u00a0<\/span>Now Create new a new layout Activity. Go to\u00a0<strong>res-&gt; right click on layout -&gt; New -&gt; Activity -&gt; Blank Activity and create list_item.xml<\/strong>\u00a0and add following code.<\/p>\n<p>Here we are creating items view that will be displayed inside each row.<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\nandroid:layout_width=\"match_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:orientation=\"vertical\"&gt;\r\n&lt;!-- TextView for the list item --&gt;\r\n&lt;TextView\r\nandroid:id=\"@+id\/name\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:padding=\"10dp\"\r\nandroid:textColor=\"#0f0\" \/&gt;\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>Step 4:<\/strong><\/span><strong>\u00a0<\/strong>Open \u00a0src -&gt; package -&gt; <strong>MainActivity.java<\/strong><\/p>\n<p>In this step we open\u00a0MainActivity\u00a0and\u00a0add the code for initiate the ListView, SlidingDrawer and a Button. Firstly we create String array and then ArrayAdapter is used to fill the data in the list. Whenever \u00a0we click on list item the name of the item is displayed by using a toast. \u00a0In this we also implement setOnDrawerOpenListener and setOnDrawerCloseListener events for changing the text of handle button.<\/p>\n<pre>package example.abhiandroid.sliderdrawerexample;\r\n\r\nimport android.os.Bundle;\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.view.Menu;\r\nimport android.view.MenuItem;\r\nimport android.widget.ArrayAdapter;\r\nimport android.widget.Button;\r\nimport android.widget.ListView;\r\nimport android.widget.SlidingDrawer;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n\r\n    String[] nameArray = {\"Aestro\", \"Blender\", \"Cupcake\", \"Donut\", \"Eclair\", \"Froyo\", \"GingerBread\", \"HoneyComb\", \"IceCream Sandwich\", \"JelliBean\", \"KitKat\", \"Lollipop\", \"MarshMallow\"};\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n        SlidingDrawer simpleSlidingDrawer = (SlidingDrawer) findViewById(R.id.simpleSlidingDrawer); \/\/ initiate the SlidingDrawer\r\n        final Button handleButton = (Button) findViewById(R.id.handle); \/\/ inititate a Button which is used for handling the content of SlidingDrawer\r\n        ListView simpleListView = (ListView) findViewById(R.id.simpleListView); \/\/ initiate the ListView that is used for content of Sl.idingDrawer\r\n        \/\/ adapter for the list view\r\n        ArrayAdapter&lt;String&gt; arrayAdapter = new ArrayAdapter&lt;String&gt;(getApplicationContext(), R.layout.list_item, R.id.name, nameArray);\r\n        \/\/ set an adapter to fill the data in the ListView\r\n        simpleListView.setAdapter(arrayAdapter);\r\n        \/\/ implement setOnDrawerOpenListener event\r\n        simpleSlidingDrawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {\r\n            @Override\r\n            public void onDrawerOpened() {\r\n                handleButton.setText(\"Close\");\r\n            }\r\n        });\r\n        \/\/ implement setOnDrawerCloseListener event\r\n        simpleSlidingDrawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {\r\n            @Override\r\n            public void onDrawerClosed() {\r\n                \/\/ change the handle button text\r\n                handleButton.setText(\"Open\");\r\n            }\r\n        });\r\n    }\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Now run the App and you will see a Button with open text. Click or slide and content will appear on screen. Again clicking on button will hide the content. This we have done using Sliding Drawer in Android.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Android, Sliding Drawer is used to hide the content out of the screen and allows the user to drag a handle to bring the content on screen. It can be used horizontally or vertically both. Sliding Drawer is a\u00a0special widget composed of two children views, one is the handle that the user\u2019s drags, and &hellip; <a href=\"https:\/\/abhiandroid.com\/ui\/slidingdrawer\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Sliding Drawer Tutorial With Example In Android Studio<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"home.php","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-1634","page","type-page","status-publish","hentry"],"acf":[],"psp_head":"<title>Sliding Drawer Tutorial With Example In Android Studio \u2013 Abhi Android<\/title>\r\n<meta name=\"description\" content=\"Understand the functioning of Sliding Drawer which consist of handle and content with example In Android Studio. Also learn about its methods and attributes in Android.\" \/>\r\n<meta name=\"robots\" content=\"index,follow\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/abhiandroid.com\/ui\/slidingdrawer\" \/>\r\n","_links":{"self":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages\/1634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/comments?post=1634"}],"version-history":[{"count":3,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages\/1634\/revisions"}],"predecessor-version":[{"id":2798,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages\/1634\/revisions\/2798"}],"wp:attachment":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/media?parent=1634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}