Can you hide an element in a layout, such as a spi

2019-03-23 08:41发布

I am working on my app which has 3 spinners in one view. Some of my activities will need to use 3 spinners, some 2, some 1, so I would like to hide them depending on the activity, if that is even possible. I am trying to do it like this so I can be as efficient as possible, but I have no idea if it is even possible.

2条回答
贼婆χ
2楼-- · 2019-03-23 09:07

Call setVisibility(View.INVISIBLE) or setVisibility(View.GONE) on the Spinners as needed to hide them. GONE means totally gone; INVISIBLE means they still take up space but no pixels are drawn.

查看更多
孤傲高冷的网名
3楼-- · 2019-03-23 09:07

You can use a View's method setVisibility: You can hide or show views using setVisibility(int visibility).

Where the argument can be INVISIBLE or GONE, depending on whether you want it to take up any space when it's invisible.

查看更多
登录 后发表回答