http://blog.csdn.net/qq_naruto/article/details/39826465
之前有用各种方式去实现侧滑的效果,像什么重写ViewGroup自己去绘制界面而实现侧滑或者使用网上大神写好的框架什么的。最近突然发现了再support v4包中有一个叫做SlidePanelLayout的东西。顾名思义,它就是实现了一个SlidePanel的布局。利用这个布局我们可以很轻易地去实现侧滑的效果。
效果如下:
这个功能实现起来非常简单,只需要引入support v4包并且在你的布局中添加SlidePanelLayout。SlidePanelLayout的两个子控件分别就是Menu和Content。代码如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.widget.SlidingPaneLayout
android:id="@+id/slidepanel"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include
android:id="@+id/menu"
layout="@layout/menu_layout"/>
<include
android:id="@+id/content"
layout="@layout/content_layout"/>
</android.support.v4.widget.SlidingPaneLayout>
</LinearLayout>
代码链接:http://download.csdn.net/detail/qq_naruto/8005757