Android android.support.v4.widget.SlidingPaneLayout Slide-off example

Source: Internet
Author: User


Slidingpanelayout for horizontal scrolling of two view, first view is left side, second view is content view


Slding_pane_layout.xml

<?xml version= "1.0" encoding= "Utf-8"? ><android.support.v4.widget.slidingpanelayout xmlns:android= "http:/ /schemas.android.com/apk/res/android "android:id=" @+id/slidingpanelayout "android:layout_width=" Match_parent "and roid:layout_height= "Match_parent" > <framelayout android:layout_width= "200DP" android:layout_height= "Match_parent" > <linearlayout android:id= "@+id/full_left" android:layout_width= "match_p Arent "android:layout_height=" match_parent "android:background=" #acd "android:gravity=" ce Nter "android:orientation=" vertical "> <button android:layout_width=" Match_paren T "android:layout_height=" wrap_content "android:onclick=" Baidu "android:text= "Baidu" android:textcolor= "#aaff00"/> <button android:layout_width= "Match_par Ent "Android:layout_height= "Wrap_content" android:onclick= "QQ" android:text= "QQ" Android:textco Lor= "#aaff00"/> <button android:layout_width= "Match_parent" android:layout _height= "Wrap_content" android:onclick= "Wangyi" android:text= "NetEase" Android:tex Tcolor= "#aaff00"/> <button android:layout_width= "Match_parent" Android:lay out_height= "Wrap_content" android:onclick= "Sina" android:text= "Sina" Android:te            Xtcolor= "#aaff00"/> </LinearLayout> <textview android:id= "@+id/small_left"            Android:layout_width= "80DP" android:layout_height= "match_parent" android:background= "#acd" android:text= "I am the shrinking state on the side. Right slide expand Sidebar, bookmark. "Android:textcolor=" #ff00 "/> </FrameLayout> <webview android:id=" @+iD/webview "android:layout_width=" match_parent "android:layout_height=" Match_parent "Android:layout_ma rginleft= "80DP"/></android.support.v4.widget.slidingpanelayout>

/** * author:stone * Email: [email protected] * TIME:15/6/11 */public class Slidingpanelayoutacti Exten    DS Activity {slidingpanelayout mslidingpanelayout;    View Msmallleft;    View Mfullleft;        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (r.layout.slding_pane_layout);        Mslidingpanelayout = (slidingpanelayout) Findviewbyid (r.id.slidingpanelayout);        Msmallleft = Findviewbyid (r.id.small_left);        Mfullleft = Findviewbyid (r.id.full_left);        Mfullleft.setalpha (0);//default full sidebar hide show min-preview side bar Mwebview = (WebView) Findviewbyid (R.id.webview);        WebSettings settings = Mwebview.getsettings ();        Settings.setjavascriptenabled (TRUE);        Webviewclient client = new Webviewclient ();        Mwebview.setwebviewclient (client); Mslidingpanelayout.setpanelslidelistener (New Slidingpanelayout.panelslidelistener () {@Override Publ Icvoid Onpanelslide (View panel, float slideoffset) {//slideoffset:close Left->open left from 0-1                System.out.println ("slide" + slideoffset);                View.setalpha (0~1)//full full display when the small should be completely invisible msmallleft.setalpha (1-slideoffset);                Mfullleft.setalpha (Slideoffset); Msmallleft.setvisibility (Mslidingpanelayout.isopen ()?            View.GONE:View.VISIBLE);            } @Override public void onpanelopened (View panel) {System.out.println ("opened"); } @Override public void onpanelclosed (View panel) {System.out.println ("Clos            Ed ");    }        });    } WebView Mwebview;    public void Baidu (view view) {Mwebview.loadurl ("http://www.baidu.com");    } public void QQ (view view) {Mwebview.loadurl ("http://www.qq.com"); The public void Wangyi (view view) {Mwebview.loadurl ("http://www.163.com ");    } public void Sina (view view) {Mwebview.loadurl ("http://www.sina.com"); }}


Android android.support.v4.widget.SlidingPaneLayout Slide-off example

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.