ListView does not resize when hiding element(s) dynamically
I have a menu ListView that has a dynamic SignOut button that should only
show when the user is logged in. The ListView has a drop shadow after it
(not set as a Footer, but rather as a View following the ListView). When I
remove the SignOut button it disappears, but the size of the ListView does
not change, so there is a transparent gap and then the dropshadow. I am
hiding the SignOut row using signOutBtn.setVisibility(View.GONE); (I have
a reference to the signOutBtn view). Also, I have verified I am not using
View.INVISIBLE anywhere since I would expect this behavior using that.
The ListView is using wrap_content for the height, and I believe this is
where the problem lies - the height is being calculated including the
SignOut button.
So, the question is, how can I make the ListView dynamically resize when a
row is shown or hidden? I would prefer not to destroy and recreate the
View, although that is what I will probably try next, since it is a
relatively simple view.
PS. I can add code samples if needed, but I do not believe this is a code
issue.
No comments:
Post a Comment