java – 如何在Android DrawerLayout中使用两个片段
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – 如何在Android DrawerLayout中使用两个片段,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3095字,纯文字阅读大概需要5分钟。
内容图文
![java – 如何在Android DrawerLayout中使用两个片段](/upload/InfoBanner/zyjiaocheng/744/95a4b2ec26724245af32f7ccb2cb5079.jpg)
我尝试使用Android NavigationDrawe – http://developer.android.com/training/implementing-navigation/nav-drawer.html
我有一个活动和两个片段.
我的主要问题是android.support.v4.widget.DrawerLayout中的布局.
一个片段使用-content_frame和其他 – content_footer.此元素将位于底部(height – wrap_content).我尝试了不同的变化,但没有奏效.所有例子都有一个片段.我做错了什么?谢谢
我的主要布局文件.用这个节目一个片段.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
>
</FrameLayout>
<FrameLayout
android:id="@+id/content_footer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
>
</FrameLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/abs__bright_foreground_disabled_holo_light"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
当改为:
<RelativeLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
>
</RelativeLayout>
<RelativeLayout
android:id="@+id/content_footer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
>
</RelativeLayout>
</FrameLayout>
显示两个片段,但彼此显示. screenshot
解决方法:
如果我正确理解您的问题,您希望在顶部有一个片段,并且您希望第二个片段作为屏幕上的页脚.目前还不清楚你是否想要滚动,所以我不会假设. DrawerLayout实际上在根据我的知识布置元素方面做的并不多,所以我建议在DrawerLayout中放置一个布局来根据需要定位片段.做一些类似于我将在下面提到的未经测试的代码:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="80" >
</FrameLayout>
<FrameLayout
android:id="@+id/content_footer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="20" >
</FrameLayout>
</LinearLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/abs__bright_foreground_disabled_holo_light"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
祝你好运!希望有所帮助!
内容总结
以上是互联网集市为您收集整理的java – 如何在Android DrawerLayout中使用两个片段全部内容,希望文章能够帮你解决java – 如何在Android DrawerLayout中使用两个片段所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。