0

I have an ImageView and I want to change it's size in runtime. So I do the following:

LayoutParams params = (LayoutParams) imgView.getLayoutParams();
params.width = size;
params.height = size
imgView.setLayoutParams(params);

The problem is that based on these new width and height I want to change my another ImageView, but seems like LayoutParams are not applied immedately, because Log put just after setLayoutParams prints old width value. So here is a question: is there any way to force ImageView to update (I already tried View.invalidate() and View.requestLayout but no success), or is there any way to detect if ImageView has finished updating, so I can use it's new parameters?

mol
  • 2,607
  • 4
  • 21
  • 40

1 Answers1

1

you can attach a viewTreeObserver. Which will get called every time layout is changed

You can follow this link

Community
  • 1
  • 1
vipul mittal
  • 17,343
  • 3
  • 41
  • 44