如何删除按钮或使其在 Android 中不可见? [英] How can I remove a button or make it invisible in Android?

查看:22
本文介绍了如何删除按钮或使其在 Android 中不可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Android 中删除按钮或使其不可见?

How can I remove a button in Android, or make it invisible?

推荐答案

将按钮可见性设置为 GONE(按钮将被完全移除"——按钮空间可用于其他小部件)或 INVISIBLE(按钮将变为透明"——它的空间将不能用于其他小部件):

Set button visibility to GONE (button will be completely "removed" -- the buttons space will be available for another widgets) or INVISIBLE (button will became "transparent" -- its space will not be available for another widgets):

View b = findViewById(R.id.button);
b.setVisibility(View.GONE);

或在 xml:

<Button ... android:visibility="gone"/>

这篇关于如何删除按钮或使其在 Android 中不可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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