The realization of the effect of Android slidingdrawer drawer _android

Source: Internet
Author: User
Tags xmlns

Slidingdrawer hides the content outside the screen and allows the user to handle to display hidden content. It can slide vertically or horizontally, it has two view components, one is the handle that can be dragged, and the other is the view of the hidden content. The controls inside it must be laid out and the handle and content must be specified in the layout file.

1, Layout layou file

Copy Code code as follows:

<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical" >
<textview
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "@string/hello_world"/>
<slidingdrawer
Android:id= "@+id/slidingdrawer"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
Android:content= "@+id/content"
Android:handle= "@+id/handle"
android:orientation= "Vertical" >
<button
Android:id= "@+id/handle"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "Slidingdraser"/>
<linearlayout <!--hidden content-->
Android:id= "@+id/content"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:background= "#00ffaa" >
<button
Android:id= "@+id/button"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "button"/>
<edittext
Android:id= "@+id/edittext"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"/>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>


2, the following is the interface after running the program

Another: You can add files to the drawable

Copy Code code as follows:

    <?xml version= "1.0" encoding= "Utf-8"?> 
    <selector xmlns: Android= "Http://schemas.android.com/apk/res/android" > 
        <item android:state_window_focused= "false" android:state_enabled= "true" android:drawable= "@drawable/handle_ Normal "/> 
        <item android:state_pressed=" true "Android: drawable= "@drawable/handle_pressed"/> 
        <item android: State_focused= "true" android:state_enabled= "true" android:drawable= "@drawable/handle_focused"/> 
        <item android:state_enabled= "true" android:drawable= "@drawable/ Handle_normal "/> 
        <item android:state_focused=" true " android:drawable= "@drawable/handle_focused"/> 
    </selector> 

Summary:

1. Important Attributes

Android:allowsingletap: Indicates whether the can be turned on or off by handle

Android:animateonclick: Indicates whether there should be an animation when the consumer presses the handle on/off.

Android:content: Hidden content

Android:handle:handle (handle)

2. Important Methods

Animateclose (): Animations are implemented when closed.

  Close (): Immediate shutdown

  GetContent (): Getting content

  Ismoving (): Indicates whether the slidingdrawer is moving.

  Isopened (): Indicates whether Slidingdrawer is all open

  Lock (): Masks Touch events.

  Setondrawercloselistener (Slidingdrawer.ondrawercloselistener Ondrawercloselistener): Called when SlidingDrawer shutdown

Setondraweropenlistener

Setondrawerscrolllistener

  Unlock (): Unblock touch event.

  Toggle (): toggle Open and close drawer slidingdrawer.

Related Article

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.