support.v4之SlidingPaneLayout简单使用
简单的布局
<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" > <!-- Left side pane. (Master) --> <FrameLayout android:id="@+id/leftpane" android:layout_width="100dp" android:layout_height="match_parent" android:layout_gravity="left" android:background="@android:color/holo_blue_dark" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="left" android:text="Menus" /> </FrameLayout> <FrameLayout android:id="@+id/rightpane" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="right" android:layout_weight="1" android:background="@android:color/white" > <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="Main Content" /> </FrameLayout> </android.support.v4.widget.SlidingPaneLayout>
简单的使用
import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.support.v4.widget.SlidingPaneLayout; import android.util.Log; import android.view.View; public class SlidingLeftPanelActivity extends Activity { private Context context; private SlidingPaneLayout pane; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sliding_left_panel); context = this; initViews(); } private void initViews() { pane = (SlidingPaneLayout) findViewById(R.id.slidingPaneLayout); pane.setPanelSlideListener(new PaneListener()); } private class PaneListener implements SlidingPaneLayout.PanelSlideListener { @Override public void onPanelClosed(View view) { Log.i("tag", "==========onPanelClosed==========="); } @Override public void onPanelOpened(View view) { Log.i("tag", "==========onPanelOpened==========="); } @Override public void onPanelSlide(View view, float arg1) { Log.i("tag", "==========onPanelSlide==========="); } } @Override public void onBackPressed() { if (pane.isSlideable() && pane.isOpen()) { pane.closePane(); } else { super.onBackPressed(); } } }
部分可见的侧边菜单与交叉渐变效果的SlidingPaneLayout
http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0208/2435.html
相关推荐
huha 2020-10-16
xfcyhades 2020-11-20
sgafdsg 2020-11-04
Michael 2020-11-03
fengyeezju 2020-10-14
ziyexiaoxiao 2020-10-14
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28