要在Xml中设置View的可见性,请使用android:visibility属性.
以下设置按钮可见性消失.当设置为Android时,Android将不会显示按钮,并且在布局计算期间不会包含它的大小.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:visibility="gone"/>
设置android:visibility =“invisible”不会显示按钮,但在布局计算期间包含它.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:visibility="invisible"/>
要以编程方式在代码中显示按钮,请调用setVisibility()方法.
Button btn = (Button)findViewById(R.id.thebuttonid);
btn.setVisibility(View.VISIBLE); //View.GONE,View.INVISIBLE are available too.