How to change layout settings while the program is running

I have an ImageView sitting on a FrameLayout. I want to be able to move this imageView by setting the field:
LayoutParams lp = new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
lp.setMargins(left, top, 0, 0);
imageView.setLayoutParams(lp);
imageView.invalidate();
However, nothing changes, and my ImageView does not move.
What am I doing wrong?
Do I need to do something other than imageView.invalidate()after I set new fields?

+3
source share
1 answer

Try it. I think it will work.

FrameLayout.LayoutParams lp=new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
0
source

Source: https://habr.com/ru/post/1765171/


All Articles