【问题标题】:How to freeze Notification bar space when use CoordinatorLayout with scrollFlag=scroll? [duplicate]使用带有scrollFlag = scroll的CoordinatorLayout时如何冻结通知栏空间? [复制]
【发布时间】:2016-06-05 19:42:06
【问题描述】:

我使用 CoordinatorLayout 滚动出 ToolBar。当 ToolBar 滚出时,通知栏的背景也会滚出。它看起来很丑。如何冻结通知栏的背景?

红色的“hello”行是附加 bar 元素的模拟。它必须不滚动出屏幕。

从这里滚动的屏幕截图

到这里

布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    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:context="ru.jollydroid.collapsingtoolbardemo.MainActivity">

    <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:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/AppTheme.PopupOverlay"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="@color/red"
            android:text="hello"/>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:behavior_overlapTop="64dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <include layout="@layout/content_main"/>
    </android.support.v4.widget.NestedScrollView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email"/>

</android.support.design.widget.CoordinatorLayout>

完整来源:https://github.com/tseglevskiy/CollapsingToolbarDemo

【问题讨论】:

    标签: android android-coordinatorlayout


    【解决方案1】:

    请删除该行

    android:fitsSystemWindows="true"
    

    来自CoordinatorLayout 因为CoordinatorLayout 不应该适合整个系统窗口。

    【讨论】:

      猜你喜欢
      • 2016-03-02
      • 2021-05-26
      • 2016-08-24
      • 1970-01-01
      • 1970-01-01
      • 2015-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多