Well, after doing some work-related Android development I went to see to fitting a SlidingDrawer to some basic content but alas things have changed since I first used it for the Letchworth app. Though deprecation doesn’t mean immediate incompatibility it does signal that it can be dropped from being supported at all in the near future.
SlidingDrawer in action – sliding out extra content
Naturally the Android developer suggestion was to just resurrect the code as its source code is available, but I kept hitting issues that weren’t elaborated in existing tips online. After finally collecting enough of a trail from various sources, I think I have all the steps you would need in one place (assuming that you’ve experienced using SlidingDrawer):
- Copy SlidingDrawer into your package. I will for this example copy and rename appropriately the class to
MySlider and place it in
- Add to
/res/values/attr.xml a copy of the sliding drawer styleables. For ease of reuse, refer the name value to your class name – in this case ‘MySlider’
<?xml version="1.0" encoding="UTF-8"?>
<attr name="handle" format="reference" />
<attr name="content" format="reference" />
<attr name="orientation" format="integer" />
<attr name="bottomOffset" format="dimension" />
<attr name="topOffset" format="dimension" />
<attr name="allowSingleTap" format="boolean" />
<attr name="animateOnClick" format="boolean" />
- Change your cloned code into using the styleable attributes that you have just declared – ie: replace all instances of
R.styleable.MySlider_bottomOffset in MySlider.java. At the end of this stage you should check if it all compiles – hopefully things are fine which would mean it’s ready to use
- How to use it: you need to add the package MySlider is in by adding it as another namespace at the top of with the xml declaration (alongside the android schema). For this example
xmlns:prettyui="http://schemas.android.com/apk/res/com.foo.prettyui" I’ve declared
prettyui as my new namespace – you will need to use this for any of the
SlidingDrawer MySlider styleable atributes – namely
content (the minimum required), so to continue:
<?xml version="1.0" encoding="utf-8"?>
..YOUR SLIDING DRAWER STUFF..
..WHICH SHOULD INCLUDE 2 LAYOUTS WITH THE IDS AS STATED IN HANDLE/CONTENT..
- The above layout attributes can be reused if you decide to extend your SlidingDrawer, say if you wish to allow it to set its height to
So, from my phone (API level 17) onwards SlidingDrawer is officially dead. Long live SlidingDrawer!