2017년 1월 12일 목요일

After screen rotation. How long to up date element size properties?


I have a canvas set to fill width. On screen rotation I get the canvas width and calculate the maximum x coordinate.
I am finding that the canvas width property is not updated straight away and canvas.width returns the pre-rotate value. Is there a way around this?

In the attached blocks. When the screen is rotated, I recalculate Graph_maxPos based on the canvas.width. 
Graph_maxPos is the maximum x coordinate in the graph.

If I wait a short while after the rotation and use the start button to reset the graph everything works fine.

screen.jpg 표시 중
--
What you can do, is to enable a clock at screen rotation, and calculate the new values when it fires the first time (then disable the clock again). Experiment with the timer values for the shortest reasonable value.

-- 
this is what I done and the same method I used to over come a similar issue when updating button graphics. I feel it is a little messy having to used timers though.
Is this type of problem inherent in Android or is it just AI?

-- 
It is just AI that is not so fast. It may well be that when you build the app that you do not have the problem, because of less overhead.

--
thanks

-- 

댓글 1개: