【发布时间】:2017-07-30 19:05:46
【问题描述】:
我正在创建一个在布局中有导航抽屉的 Android 应用:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/navigation_select_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/navigation_drawer_header_layout"
app:menu="@menu/main_drawer_options" />
</android.support.v4.widget.DrawerLayout>
navigation_drawer_header_layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textViewButtonCloseDrawer"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="X"/>
</RelativeLayout>
标题布局已添加但不显示,除非我为 TextView 添加上边距或向 RelativeLayout 添加一些填充,从而将 TextView 向下推。
为什么它不会按照标题布局中的定义显示?为什么需要推送布局才能显示?
【问题讨论】:
-
您运行该应用的 android 版本是什么?
-
你能在打开导航器的情况下添加图片吗?
-
@BrunoFerreira 我正在尝试在 android 5.1.1 上运行。我添加了一个带有大图像的图像视图,同样的事情发生了。我只能看到图像的下半部分,因为上半部分是隐藏的。这也让我意识到它隐藏在我手动添加的工具栏后面
-
尝试通过使工具栏可见性消失来检查是否隐藏在工具栏后面。并且您在 drower 布局中添加工具栏?
-
@BrunoFerreira 你让我意识到问题出在工具栏上,并且问题已经在另一个问题中得到解决。如果你愿意,你可以用原始问题的链接来总结答案,我会接受你的答案。原问题:stackoverflow.com/questions/36826829/…
标签: android android-layout navigation-drawer android-navigationview