Adariel Lzinski
Adariel Lzinski

Reputation: 1121

How to set Scroll View visibility programmatically?

I have 3 Buttons, 3 Scroll Views, and some Textviews and pictures and what not.

The 3 Buttons I want to be able to show a different Scroll View when they are clicked.

So clicking Button #1 would show Scroll View #1 and hide Scroll View #2 & #3

etc....

Is there a way to do this programmatically? Like in an OnClick() Event?

Upvotes: 0

Views: 1535

Answers (2)

Tal Kanel
Tal Kanel

Reputation: 10785

you can use the setVisiblility() method:

mScrollView.setVisibility(View.GONE);

by setting View.GONE you'll view will become invisible, and will not take any actual space inside the layout container it reside in.

then when you'll want to make it visible again, use the:

mScrollView.setVisibility(View.VISIBLE);

Upvotes: 1

Related Questions