Android learning notes (): Multi-page display-Use of s0000ingdrawer

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.