Android-Slide Drawer Slidingdrawer (non-original)

Source: Internet
Author: User

Slidingdrawer (sliding drawer) hides the contents of the screen and allows the user to drag a handle to show hidden content. The slidingdrawer can be used vertically or horizontally. It consists of two sub-views: One is the user-dragged handle (handle) and the other is the content (contents) that changes with the drag. Slidingdrawer should be used as an overlay of the internal layout, meaning that the slidingdrawer should use Framelayout or relativelayout layouts. The size of the slidingdrawer determines the amount of space it takes to display its contents, so its size is generally defined as match_parent. Slidingdrawer must specify the ID of handle and content in the XML layout:

  

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:orientation=" vertical " > <!--can set the direction of the display--<slidingdrawer android:id= "@+id/slidingdraw" android:layout_width= " Match_parent "android:layout_height=" match_parent "android:content=" @+id/content "android:orientation            = "Horizontal" android:handle= "@+id/handle" > <listview android:id= "@id/content"            Android:layout_width= "Match_parent" android:layout_height= "match_parent"/> <imageview Android:id= "@id/handle" android:layout_width= "88dip" android:layout_height= "44dip" Androi d:contentdescription= "TODO" android:src= "@drawable/ic_launcher"/> </slidingdrawer></linearlayou T>

public class Mainactivity extends Activity {//Declaration slidingdrawer Private Slidingdrawer mdrawer;private ImageView Mimageview                              ;p rivate ListView lvnews;private String news[] ={"emotional design in Internet products", "effectively guide the business value of social products", "Mobile developers: 90 The latter to the world", "user experience: from the app loading page," The flat interface design attracts the user "," the intersection of the entity and the digital World "," the Network community user growth 5 Thinking mode "," Ten noteworthy traditional enterprise electricity                              Business "," 2013 ten Hot Technology Development trend "," understand product development link: Circular design theory "," four levels of customer loyalty ",                              "The sticker on the back of your phone makes it easy to recharge", "How does Internet company inspire your desire to consume", "Information collection and management for efficient work"};@ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate  ); Setcontentview (r.layout.activity_main);//Get Slidingdrawer Mdrawer = (slidingdrawer) Findviewbyid (R.id.slidingdraw ); Mimageview = (ImageviEW) Findviewbyid (r.id.handle);//Get ListView and populate content lvnews = (ListView) Findviewbyid (r.id.content); lvnews.setadapter (New Arrayadapter < String > (this, Android. R.layout.simple_list_item_1, News));//Monitor Open drawer event Mdrawer.setondraweropenlistener (new slid Ingdrawer.ondraweropenlistener () {@ overridepublic void ondraweropened () {Mimageview.setimageresource (R.drawable.ic _launcher);}} )///Monitor Close drawer event Mdrawer.setondrawercloselistener (new Slidingdrawer.ondrawercloselistener () {@ overridepublic void OnDra Werclosed () {mimageview.setimageresource (r.drawable.ic_launcher);}} );}}

Recommend a great God's custom Slidingdrawer

Property

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

Android:animateonclick: Indicates whether there is an animation when the consumer presses the handle to open/close.

Android:content: Hidden content

Android:handle:handle (handle)

Method

  Animateclose (): animations are implemented when off.

  Close (): Instant off

  GetContent (): Get content

  Ismoving (): Indicates whether the slidingdrawer is moving.

  Isopened (): Indicates whether Slidingdrawer is all open

  Lock (): Mask Touch event.

  Setondrawercloselistener (Slidingdrawer.ondrawercloselistener Ondrawercloselistener): Called when SlidingDrawer is closed

  Unlock (): Unblock touch event.

  Toggle (): toggles the open and closed drawer slidingdrawer.

Android-Slide Drawer Slidingdrawer (non-original)

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.