Android应用程序中的片段布局
我是Android应用程序的新手,刚刚开始学习。我正在使用导航抽屉和片段编写一个应用程序 布局很好,但片段的内容隐藏在导航顶部栏中 预期显示类似于 但是,布局就是这样的 下一个日期隐藏在操作栏后面 布局代码为Android应用程序中的片段布局,android,android-layout,android-fragments,Android,Android Layout,Android Fragments,我是Android应用程序的新手,刚刚开始学习。我正在使用导航抽屉和片段编写一个应用程序 布局很好,但片段的内容隐藏在导航顶部栏中 预期显示类似于 但是,布局就是这样的 下一个日期隐藏在操作栏后面 布局代码为 在您的框架布局中添加topMargin: android:layout_marginTop="56dp" 将其添加到框架布局中 app:layout_behavior="@string/appbar_scrolling_view_behavior" 还有这个 xmlns:app="
在您的
框架布局中添加topMargin
:
android:layout_marginTop="56dp"
将其添加到框架布局中
app:layout_behavior="@string/appbar_scrolling_view_behavior"
还有这个
xmlns:app="http://schemas.android.com/apk/res-auto"
在协调器布局中放置一个相对布局,并将规则添加到框架布局中,使其位于
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中(但不是必需的) 诀窍在于这一行: app:layout_behavior=“@string/appbar_scrolling_view_behavior” 如果你给协调人的孩子一个建议,他们的行为会有所不同 .
我建议尝试删除android:fitsystemwindows=“true”
有两种情况出现fitsystemwindows=“true”
。尝试删除两个但相同的输出屏幕
<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>
<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>