|
|
This figure can be in the Android doc, mistakenly operation, the original picture deleted, so the above is just an example, no transparency effect |
Slidedrawer is a way to display multiple (two pages). As shown in the image on the left, normal, we display Hello's label, when we press the Slidingdrawer ImageView below, that is, the icon on the right, you can display the contents of slidedrawer, such as the figure. The slidingdrawer can switch between open and close two states. Open overlay, not all layout can support this overlay, as Slidingdrawer container, such as linearlayout can not, generally use relativelayout and framelayout. The following is an example XML file that uses Framelayout as a container:
<?xml version= "1.0" encoding= "Utf-8"?>
<FramelayoutXmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:background= "#FF8888CC" >
<textview android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
Android:textstyle= "Bold"
android:gravity= "Center"
android:text= "Hello"/> <!--we used a simple textview to represent the contents of the original page, which is displayed when the Slidingdrawer is close, such as left-to-
<SlidingdrawerAndroid:id= "@+id/c96_drawer"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
<!--Slidingdrawer contains two important parameters handle and content, similar to the tab and contents, we need to set the relevant ID here so that the reference--
Android:handle= "@+id/c96_handle"
Android:content= "@+id/c96_content" >
<imageviewandroid:id= "@id/c96_handle"<!--is consistent with Slidingdrawer's handle ID, which is generally an image, but we can also set it to button and so on, but not aesthetically pleasing. -
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:src= "@drawable/tray_handle_normal"/>
<button android:id= "@id/c96_content" <!--and the content ID of the slidingdrawer are consistent, here we simply use the Button to handle-
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:text= "I am in Here"/>
</Slidingdrawer>
</FrameLayout>
The source file does not require special handling, and for Slidingdrawer, open (), close (), toggle () can also be animated Anmiateopen (), Animateclose (), and Animatetoggle (). You can set Android:animateonclick = "true" in XML, and the default is true.
We can also set lock () and unlock ().
We can listen to Slidingdrawer events: openen,closed,scrolled (user drag tag). For example:setondrawercloselistener (Slidingdrawer.ondrawercloselistener ondrawercloselistener).
RELATED links: My Andriod development related articles
Android Learning Note (24): Multi-page display-slidingdrawer use