FAB消失了一段时间 [英] Gone FAB becames visible for a while

查看:91
本文介绍了FAB消失了一段时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的布局中有来自设计支持库的FAB:

I have FAB from Design Support Library in my layout:

<?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.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill_vertical"
        android:paddingBottom="?attr/actionBarSize"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

           //....

        </FrameLayout>


    </android.support.v4.widget.NestedScrollView>

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/image_iv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:scaleType="fitXY"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7"
                tools:ignore="ContentDescription" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

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

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

    <!-- FAB -->
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/favorite_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        android:clickable="true"
        android:src="@drawable/ic_star_rate"
        android:visibility="gone"
        app:layout_anchor="@id/container"
        app:layout_anchorGravity="bottom|right" />

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

如您所见,其可见性设置为消失". 但是活动开始后,它会在屏幕上显示一段时间(您可以在视频(左上角),然后消失.为什么?

As you can see, its visibility is set to 'gone'. But when the Activity starts, it appears on screen for a while (you can see it on this video, upper-left corner), then it dissapears. Why?

推荐答案

前一段时间,我提交了错误报告说出了问题,但这是答复

A while ago I submitted a bug report saying the problem but this was the reply

现在唯一更改可见性的时间是您设置了 FloatingActionButton具有AppBarLayout锚点(并以

The only time the visibility is now changed is when you set a FloatingActionButton to have an AppBarLayout anchor (and is working as intended).

话虽如此,但我成功使用内置的show/hide方法而不是设置可见性来隐藏FAB

That being said I had success hiding the FAB by using the built in show/hide methods instead of setting the visibility

这篇关于FAB消失了一段时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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