user1610719
user1610719

Reputation: 1303

ScrollView still scrolling with hidden contents

I have a ScrollView with a RelativeView beneath it. Within that RelativeView, there are 3 views in it. 2 of those 3 are initially hidden.

enter image description here

Even though on my phone the scroller_rel doesn't take up the whole screen, I can still scroll through as if scroller_rel2 and scroller_rel3 are there and not hidden.

Programmatically I will decide if scroller_rel2 and scroller_rel3 are hidden or visible, and I'm wondering how to also then decide if we should be able to scroll or not.

The easy way to ask this question is: How can I programmatically tell ScrollView the height of the visible contents, so that if the contents are not larger than the container, we disable scrolling, and if say 2 of the 3 are showing, how can we then enable scrolling only to the bottom of scroller_rel2?

Upvotes: 1

Views: 498

Answers (1)

mithunm93
mithunm93

Reputation: 571

The reason you're having this problem is because setting the view to be View.INVISIBLE does just that, but it still takes up space in your layout, so that's why you can still scroll. What you should be using is View.GONE, this actually sets the view to be invisible and it removes it from the layout. Check out the documentation here:

GONE

INVISIBLE

Upvotes: 3

Related Questions