Android Learning Note (24): Use of multi-page display-slidingdrawer

Source: Internet
Author: User


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

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.