【问题标题】:Content behind CoordinatorLayout AppBarLayoutCoordinatorLayout AppBarLayout 背后的内容
【发布时间】:2015-12-27 15:17:22
【问题描述】:

我正在为我的应用创建设置活动/布局。我有一个CoordinatorLayout 和一个AppBarLayoutToolbar,然后在它下面包括content_settings.xml。加载内容时,.xml 文件位于应用栏后面。

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

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

content_settings.xml 只是一个 FrameLayoutPreferenceFragment 替换

<?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" />

【问题讨论】:

    标签: android xml android-toolbar android-coordinatorlayout


    【解决方案1】:

    在我的情况下,工具栏下的视图不可滚动,因此即使接受的答案确实停止了重叠,它也会将内容向下推到工具栏的高度,从而将元素推到屏幕外。 在这种情况下,解决方案是同时删除

    app:layout_scrollFlags
    

    来自我包含/与其他具有滚动视图的布局共享的工具栏。

    【讨论】:

      【解决方案2】:

      将此添加到您的 Recyclerview 中:

      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      

      【讨论】:

      • 感谢工作,我没有 Recyclerview,但我将它添加到 FrameLayout,它工作。我更新了我的问题。
      • 这确实将事情降低了,因此它不再位于工具栏下方。但是,当向下滚动时,不再显示底部的首选项,因为 FrameLayout(或您用来保存 PreferenceFragment 的任何东西)位于黑色屏幕按钮栏(返回、主页等)后面。至少,这就是发生在我身上的事情。还没有找到好的解决方案。
      猜你喜欢
      • 1970-01-01
      • 2015-09-18
      • 2015-12-22
      • 2015-12-07
      • 2017-05-31
      • 2016-03-30
      • 2016-03-12
      相关资源
      最近更新 更多