1

How do you scale one view to another? I tried finding scale x and scale y by dividing the width and height of each view, but it doesn't return the right value.

Scale a -> b.

a.setPivotX(0);
a.setPivotY(0);
a.setScaleX(b.getWidth() / a.getWidth())
a.setScaleY(b.getHeight() / a.getHeight())

1 Answers1

0

firstly, you should call getWidth() and getHeight() after the view is be measured maybe after onResume(). this question maybe helpful

secondly, getWidth() and getHeight() return int, int/int will get a int but not a float. you may do like this (float) getWidth() / getHeight().

sorry for my poor English.

Community
  • 1
  • 1
albuscrow
  • 61
  • 1
  • 6