【问题标题】:Android AppBarLayout collapse toolbar and show scrim colors without delayAndroid AppBarLayout 折叠工具栏并立即显示稀松布颜色
【发布时间】:2016-02-19 18:03:42
【问题描述】:

我有一个 CollapsingToolbarLayout,背景中有一个视差图像,我以编程方式设置了稀松布颜色,如果背景上没有显示图像,我想在启动活动时折叠工具栏,所以在活动开始时我检查是否没有图像然后我在 AppBarLayout 上调用 setExpanded(false, false),但显示稀松布颜色大约需要 2 秒,我需要调用任何方法来强制它在活动创建时显示稀松布颜色?或者是否有任何其他解决方法可以强制在创建时显示这种稀松布颜色?

这是我的布局资源:

<?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">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="270dp">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_collapseMode="parallax" />
            <include layout="@layout/toolbar"/>

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

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

    <include layout="@layout/content" />
</android.support.design.widget.CoordinatorLayout>

【问题讨论】:

    标签: android android-layout android-toolbar android-collapsingtoolbarlayout android-appbarlayout


    【解决方案1】:

    我找到了解决这个问题的方法:在折叠方法之后立即在 CollapsingToolbarLayout 中调用 setScrimsShown(true, false)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-05
      • 1970-01-01
      • 1970-01-01
      • 2016-06-15
      • 1970-01-01
      • 2016-01-26
      相关资源
      最近更新 更多