我正在使用以下代码为线性布局设置“visibility = gone”
//onCreate method
//setcontentview
. . . .
LinearLayout rlayout1 = (LinearLayout) findViewById(R.id.readerBottomLayout);
rlayout1.setVisibility(2);
但是当活动开始时,控件仍然可见。为什么?任何想法?
答案 0 :(得分:9)
设置rlayout1.setVisibility(View.INVISIBLE)
答案 1 :(得分:9)
是的,view.GONE和view.INVISIBLE都可以。它以前不起作用的原因是因为two(2)是不正确的整数值。
set.Visibility的正确值为:
0 = visible
4 = invisible
8 = gone
答案 2 :(得分:2)
您也可以这样做:
Get Parent layout object through its id
Get layout which you want to remove/hide through its id
parentlayout.remove(childlayout);