0

I have an android View X and Y where X has to be manipulated based on the dimensions of Y (specifically, X and all its contents must be scaled up to Y without its aspect ratio being changed). I do this by working out the new (larger) size of X and setting scaleX and scaleY accordingly. Please tell me if there is a better way! If not, my second problem is - I would like this to be done in Activity.onCreate or onStart or onResume. But in these the dimensions of X and Y are reported as 0.0. Is there any way I can do this on activity start after Y is laid out so its dimensions are not 0.0.

Regards, Steve Kucera

stevenkucera
  • 3,855
  • 2
  • 18
  • 13
  • See if this help: http://stackoverflow.com/questions/8356679/good-time-to-manually-layout-an-activitys-view – Code Poet Dec 15 '11 at 04:16

1 Answers1

0

Any view in android goes through several steps before it appears on screen. Firat of all it goes to measure() - here will be field measuredHeight and measuredWidth. Then it goes to layout() and only after this method finish view has params width and height. So, you can provide your own view, that will contains both X and Y, and there, while measure and layout, change width or height of child X.

Jin35
  • 8,602
  • 3
  • 32
  • 52