如何显示和隐藏Google Material FloatingAction按钮

问题描述 投票:0回答:1

我想以编程方式显示/隐藏Google Material Floating Action按钮。我正在使用Google材料库

implementation 'com.google.android.material:material:1.1.0'

并使用以下代码

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    FloatingActionButton fab = findViewById(R.is.fab);

    fab.hide() // This is the method to hide the button as the Documentation But This does not hide the button

    fab.setVisibility(View.GONE) // Neither this work, 
}

还有其他隐藏方法吗?

android material-design floating-action-button
1个回答
0
投票

检查您的xml文件以进行锚点视图修改这样的内容

此链接可能对您有所帮助:

Stackoverflow link not able to hide fab button

© www.soinside.com 2019 - 2024. All rights reserved.