CoordinatorLayout AppBarLayout 背后的内容 [英] Content behind CoordinatorLayout AppBarLayout

查看:30
本文介绍了CoordinatorLayout AppBarLayout 背后的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的应用创建一个设置活动/布局.我有一个带有 AppBarLayoutToolbarCoordinatorLayout,然后在它下面包含 content_settings.xml.当内容加载时,.xml 文件在应用栏后面.

我正在使用相同的设置来加载主要内容,它工作正常,但由于某种原因在设置"部分中无法正确呈现.

activity_settings.xml

解决方案

将此添加到您的 Recyclerview :

app:layout_behavior="@string/appbar_scrolling_view_behavior"

I was creating a settings activity/layout for my app. I have a CoordinatorLayout with an AppBarLayout and Toolbar, then beneath that it includes content_settings.xml. When the content loads the .xml file is behind the app bar.

I'm using this same setup to load the main content and it works fine, but for some reason isn't rendering correctly within the Settings section.

activity_settings.xml

<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>

<include layout="@layout/content_setting" />

The content_settings.xml is just a FrameLayout that is replaced by a PreferenceFragment

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/settings_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

解决方案

add this to your Recyclerview :

app:layout_behavior="@string/appbar_scrolling_view_behavior"

这篇关于CoordinatorLayout AppBarLayout 背后的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆