Android android. support. v4.widget. SlidingPaneLayout slide example, android slide menu
SlidingPaneLayout is used to scroll two views horizontally. The first view is the left side, and the second view is the 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" android: layout_height = "match_parent"> <FrameLayout android: layout_width = "200dp" android: layout_height = "match_parent"> <LinearLayout android: id = "@ + id/full_left" android: layout_width = "match_parent" android: layout_height = "match _ Parent "android: background =" # acd "android: gravity =" center "android: orientation =" vertical "> <Button android: layout_width =" match_parent "android: layout_height = "wrap_content" android: onClick = "baidu" android: text = "baidu" android: textColor = "# aaff00"/> <Button android: layout_width = "match_parent" android: layout_height = "wrap_content" android: onClick = "qq" android: text = "QQ" android: textColor = "# aaff00"/> <Ton android: layout_width = "match_parent" android: layout_height = "wrap_content" android: onClick = "wangyi" android: text = "Netease" android: textColor = "# aaff00"/> <Button android: layout_width = "match_parent" android: layout_height = "wrap_content" android: onClick = "sina" android: text = "sina" android: textColor = "# aaff00"/> </LinearLayout> <TextView android: id = "@ + id/small_left" android: layout_width = "80dp" android: layou T_height = "match_parent" android: background = "# acd" android: text = "I am the shrinking State of the side. Slide right to expand the sidebar and bookmarks. "Android: textColor =" # ff00 "/> </FrameLayout> <WebView android: id =" @ + id/webview "android: layout_width =" match_parent "android: layout_height = "match_parent" android: layout_marginLeft = "80dp"/> </android. support. v4.widget. slidingPaneLayout>
/*** Author: stone * email: aa86799@163.com * time: 15/6/11 15 05 */public class SlidingPaneLayoutActi extends 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. s Lidingpanelayout); mSmallLeft = findViewById (R. id. small_left); mFullLeft = findViewById (R. id. full_left); mFullLeft. setAlpha (0); // The default full sidebar hides the display of the smallest-previewed sidebar mWebView = (WebView) findViewById (R. id. webview); WebSettings settings = mWebView. getSettings (); settings. setJavaScriptEnabled (true); WebViewClient client = new WebViewClient (); mWebView. setWebViewClient (client); mSlidingPaneLayout. setPanelSlideLis Tener (new SlidingPaneLayout. panelSlideListener () {@ Override public void onPanelSlide (View panel, float slideOffset) {// slideOffset: close left-> open left from 0-1 System. out. println ("slide" + slideOffset); // view. setalpha (0 ~ 1) // when full is displayed, small should be completely invisible to 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 ("closed") ;}}) ;}webview mWebView; public void baidu (View view) {mWebView. loadUrl ("http://www.baidu.com");} public void qq (View view) {mWebView. loadUrl ("http://www.qq.com");} public void wangyi (View view) {mWebView. loadUrl ("http://www.163.com");} public void sina (View view) {mWebView. loadUrl ("http://www.sina.com ");}}