I have multiple custom views rendered on my screen in RelativeLayout
using LayoutParams
. Now first time user touches on view it increase it's size, after that when user once again clicks on that view, that view should get disappear. Now the problem is when a view gets disappeared other views on screen changes their size and location. By debugging I found that this happens when I pass dynamic values as width and height in LayoutParams
. If I go for static then all works good. But then I'm not able to increase the size of view. How can I solve this? I also tried changing View.GONE
to View.INVISIBLE
but that also doesn't help.
I create all views in code and place them on screen. In my xml I don not have any view entry. I do this because initial size of views should be random. So I create view and assign him initial size in LayoutParams(width, height)
and then use topMargin
and leftMargin
to place them at various positions on screen. More details can be found here: Custom object click issue in android