导航抽屉中的片段布局Android应用程序
问题描述:
我是Android应用程序的新手,刚开始学习。我正在写使用抽屉式导航和片段导航抽屉中的片段布局Android应用程序
这是工作的罚款与布局,但与片段内容是隐藏的导航顶栏里面
期待的显示就像是一个应用程序是
但是,这是布局如何
NEXT DATE背后隐藏的动作条
代码布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.thecoders.periodtracker.MainActivity">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>
<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/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
答
中添加这您FrameLayout里。
app:layout_behavior="@string/appbar_scrolling_view_behavior"
这也是。
xmlns:app="http://schemas.android.com/apk/res-auto"
+0
Thankx @Android插孔,它的工作... –
答
添加TOPMARGIN在Framelayout
:
android:layout_marginTop="56dp"
答
把一个相对布局协调布局内添加规则,以你的框架布局,它应该是低于像下面appBarLayout
东西:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/app_bar_layout"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
答
你或许应该换你framLayout一个NestedSCrollView内(不尽管必要)。
关键是这一行:
应用:layout_behavior = “@字符串/ appbar_scrolling_view_behavior”
的CoordinatorLayout的孩子会表现不同,如果你给他们一个 Behavior。
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Rest of the code there -->
</FrameLayout>
</android.support.v4.widget.NestedScrollView>
我建议尝试删除'机器人:fitsSystemWindows = “真”' –
有两个次数'fitsSystemWindows的= “真正的”'。试图删除两个,但相同的输出屏幕 –