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.