Android实现3种侧滑效果(仿qq侧滑,抽屉侧滑,普通侧滑)

  

自己实现了一下侧滑的三种方式(注释都写代码里了)
  

  

本文演示下载地址:Andriod侧滑

  

本文实现所需框架:nineoldandroids下载地址:nineoldandroids

  

<强> 1。普通侧滑:
  

  

主要是基于HorizontalScrollView做的:示例代码如下
  

  

主要布局:

        & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt; RelativeLayout xmlns: android=" http://schemas.android.com/apk/res/android "      xmlns: gaoyu=" http://schemas.android.com/apk/res/gaoyu.com.myapplication "      xmlns:工具=" http://schemas.android.com/tools "   android: id=癅 + id/activity_qqsideslip”   android: layout_width=" match_parent "   android: layout_height=" match_parent "   工具:上下文=癵aoyu.com.myapplication.sideslip.QQSideslipActivity”比;      & lt; !——xmlns: gaoyu自定义命名空间原有到res +包名——比;      & lt; gaoyu.com.myapplication.sideslip.SlidingMenu_qq   android: id=癅 + id/SlMenu_sideslip”   android: layout_width=" wrap_content "   android: layout_height="宽和"   gaoyu: rightPadding=" 100 dp”比;      LinearLayout & lt;   android: layout_width=" wrap_content "   android: layout_height=" match_parent "   面向android:="水平"比;      & lt;包括布局=癅layout/sideslip_menu”/比;   & lt; !——这个LinearLayout就是内容——比;   LinearLayout & lt;      android: layout_width=" match_parent "   android: layout_height=" match_parent "   android:背景=癅drawable/滑动”比;      & lt;按钮   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: onClick=" onClick_sideslip_qq "   android:文本="切换菜单”/比;   & lt;/LinearLayout>      & lt;/LinearLayout>   & lt;/gaoyu.com.myapplication.sideslip.SlidingMenu_qq>         & lt;/RelativeLayout>      之前      

菜单的布局

        & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt; RelativeLayout xmlns: android=" http://schemas.android.com/apk/res/android "   android: layout_width=" match_parent "   android: layout_height=" match_parent "   面向android:=按怪薄北?      LinearLayout & lt;   android: layout_width=" match_parent "   android: layout_height=" wrap_content "   android:取向=按怪薄?   android: layout_centerInParent=" true "比;   & lt;使用   android: layout_width="宽和"   android: layout_height=皐rap_content”比;   & lt; ImageView   android: id=癅 + id/iv_sideslip1”   android: layout_width=" 50 dp”   android: layout_height=" 50 dp”   android: layout_marginTop=" 20 dp”   android: layout_marginBottom=" 20 dp”   android: layout_marginLeft=" 20 dp”   android: src=" https://www.yisu.com/zixun/@drawable/图标“/比;   & lt; TextView   android: layout_centerVertical=" true "   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_toRightOf=癅 + id/iv_sideslip1”   android: layout_marginLeft=" 20 dp”   android:文本="第一个item”/比;   & lt;/RelativeLayout>   & lt;使用   android: layout_width="宽和"   android: layout_height=皐rap_content”比;   & lt; ImageView   android: id=癅 + id/iv_sideslip2”   android: layout_width=" 50 dp”   android: layout_height=" 50 dp”   android: layout_marginTop=" 20 dp”   android: layout_marginBottom=" 20 dp”   android: layout_marginLeft=" 20 dp”   android: src=" https://www.yisu.com/zixun/@drawable/图标“/比;   & lt; TextView   android: layout_centerVertical=" true "   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_toRightOf=癅 + id/iv_sideslip2”   android: layout_marginLeft=" 20 dp”   android:文本="第二个项目”/比;   & lt;/RelativeLayout> & lt;使用   android: layout_width="宽和"   android: layout_height=皐rap_content”比;   & lt; ImageView   android: id=癅 + id/iv_sideslip3”   android: layout_width=" 50 dp”   android: layout_height=" 50 dp”   android: layout_marginTop=" 20 dp”   android: layout_marginBottom=" 20 dp”   android: layout_marginLeft=" 20 dp”   android: src=" https://www.yisu.com/zixun/@drawable/图标“/比;   & lt; TextView   android: layout_centerVertical=" true "   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_toRightOf=癅 + id/iv_sideslip3”   android: layout_marginLeft=" 20 dp”   android:文本="第三个项”/比;   & lt;/RelativeLayout> & lt;使用   android: layout_width="宽和"   android: layout_height=皐rap_content”比;   & lt; ImageView   android: id=癅 + id/iv_sideslip4”   android: layout_width=" 50 dp”   android: layout_height=" 50 dp”   android: layout_marginTop=" 20 dp”   android: layout_marginBottom=" 20 dp”   android: layout_marginLeft=" 20 dp”   android: src=" https://www.yisu.com/zixun/@drawable/图标“/比;   & lt; TextView   android: layout_centerVertical=" true "   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_toRightOf=癅 + id/iv_sideslip4”   android: layout_marginLeft=" 20 dp”   android:文本="第四个项”/比;   & lt;/RelativeLayout> & lt;使用   android: layout_width="宽和"   android: layout_height=皐rap_content”比;   & lt; ImageView   android: id=癅 + id/iv_sideslip5”   android: layout_width=" 50 dp”   android: layout_height=" 50 dp”   android: layout_marginTop=" 20 dp”   android: layout_marginBottom=" 20 dp”   android: layout_marginLeft=" 20 dp”   android: src=" https://www.yisu.com/zixun/@drawable/图标“/比;   & lt; TextView   android: layout_centerVertical=" true "   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_toRightOf=癅 + id/iv_sideslip5”   android: layout_marginLeft=" 20 dp”   android:文本="第五个项”/比;   & lt;/RelativeLayout>   & lt;/LinearLayout>      & lt;/RelativeLayout>      

Android实现3种侧滑效果(仿qq侧滑,抽屉侧滑,普通侧滑)