|
|
This figure can be deleted by mistake in the android doc, so the above is just an example, with no transparency effect |
SlideDrawer is a display mode for multiple (two pages. As shown in the left figure above, normally, we display the Hello Label. When we press the Image view of SlidingDrawer, that is, the icon shown in the right figure, we can display the content of SlideDrawer, as shown in the figure below. SlidingDrawer can be switched between Open and Close statuses. Not all Layout supports this overlay mode. It is not supported as the container of SlidingDrawer, such as LinearLayout. RelativeLayout and FrameLayout are generally used. The XML file in the example uses FrameLayout as the 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"/> <! -- A simple textview is used to indicate the content of the original page. It is displayed when slidingdrawer is close, as shown in the left figure. -->
<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 label and content, we need to set the relevant ID here to reference -->
Android: handle = "@ + ID/c96_handle"
Android: content = "@ + ID/c96_content">
<ImageviewAndroid: Id = "@ ID/c96_handle"
<! -- It is the same as the Handle ID of slidingdrawer. Generally, it is an image. Of course, we can also set it to button or another one, but it is not beautiful. -->
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: src = "@ drawable/tray_handle_normal"/>
<Button android: id = "@ id/c96_content" <! -- It is consistent with the content id of SlidingDrawer. Here we use a Button to process it. -->
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: text = "I am in Here"/>
</Slidingdrawer>
</FrameLayout>
The source file does not need to be specially processed. For SlidingDrawer, you can open (), close (), toggle (), or use anmiateOpen (), animateClose (), and animateToggle () as animations (). You can set android: animateOnClick = "true" in XML. The default value is true.
We can also set lock () and unlock ().
We can listen to SlidingDrawer events: openen, closed, and scrolled (users drag labels ). For example, setOnDrawerCloseListener (s0000ingdrawer. OnDrawerCloseListener onDrawerCloseListener ).
Related Links: My Andriod development articles