首页 > 解决方案 > 我无法隐藏浮动操作按钮?

问题描述

我试图通过单击按钮隐藏我的 FAB,但它不起作用。?

我的 XML

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fabbb"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentBottom="true"
    android:layout_margin="@dimen/_10sdp"
    android:src="@drawable/ic_arrow_forward_black_24dp"
    android:tint="@color/md_white_1000" />

<Button
    android:id="@+id/show"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/_10sdp"
    android:text="HIDE" />

我的活动

show.setOnClickListener {
        fabbb.visibility == View.GONE
    }

标签: androidandroid-studioandroid-layoutfloating-action-buttonmaterial-components-android

解决方案


使用方法hide

fab.hide();

推荐阅读