脚本宝典收集整理的这篇文章主要介绍了Android App中DrawerLayout抽屉效果的菜单编写实例,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_304_5@
不用切换到另一个页面,也不用去按菜单的硬件按钮,直接在界面上一个按钮点击,菜单就滑出来,而且感觉能放很多东西。 库的引用: 首先, DrawerLayout这个类是在Support Library里的,需要加上andROId-support-v4.jar这个包。
然后程序中用时在前面导入import android.support.v4.widget.DrawerLayout;
如果找不到这个类,首先用SDK Manager更新一下Android Support Library,然后在Android SDK\extras\android\support\v4路径下找到android-support-v4.jar,复制到项目的libs路径,将其Add to Build Path.
代码1 布局:
<android.support.v4.widget.DrawerLayout
XMlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<!-- main content must be the First element of DrawerLayout because IT will be drawn first and drawer must be on top of it -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
以上是脚本宝典为你收集整理的Android App中DrawerLayout抽屉效果的菜单编写实例全部内容,希望文章能够帮你解决Android App中DrawerLayout抽屉效果的菜单编写实例所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。