In the first part, I showed you how to use a basic Sliding Drawer in Android. In this post I’ll show you how to make your Sliding Drawers fancier by changing the handle image when the Sliding Drawers is open and when it is closed. The complete source code is at the bottom.
- Save the two images from here and here. Name them help_handle_open and help_handle_close respectively.
- Navigate to <yourprojectname> -> res -> drawable-ldpi/mdpi/hdpi/xhdpi/xxhdpi.
- Right click and select New -> Android XML file. Choose selector from the Root Element list. Name the xml file help_handle_customizer.
- Paste the following code in it.
- In the ImageView which you have for your SlidingDrawer Handle change the @android:src attribute value to @drawable/help_handle_customizer.
Now, when you run it on the emulator or an actual device, you can see the handle images changing based on whether the Sliding Drawer is open or close.
COMPLETE SOURCE CODE