在android开发中,左右侧滑菜单的开发已成为我们现在开发的必备技术之一,再次之前,我没有做过相类似的demo,但是项目的开发有要求有这样的效果,而且大家都知道,虽然网上由开源的代码,但是不仅种类多,看着一个头两个大,而且代码不好分离。因此我们无法简化成自己的demo,为此,还查阅了很多别人的资料,最后做出了自己想要的效果,具体效果如下所示:
图1 左边菜单
图2 右边菜单
今天要做的是把两个效果结合在一起,左右侧滑菜单
话不多说,直接上代码:
activity_main.xml:
<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.DrawerLayout
android:id="@+id/dl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/tv" >
<!-- 作为侧拉菜单 主页面显示的效果 要写在布局的最上面 首先进行加载 -->
<FrameLayout
android:id="@+id/fl"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0"
android:layout_gravity="left" >
</ListView>
<LinearLayout
android:id="@+id/ll"
android:layout_width="200dp"
android:layout_height=