-1

I'm developing an android app in which I've created my own timers view , when I start showing the view on the screen (Even when I change the screen orientation) nothing is in position :

enter image description here

But as soon as I touch the screen every view take it's place...

enter image description here

See the attached pictures to understand more the problem. Can anyone help me please ?

wael ben hamda
  • 127
  • 1
  • 9

1 Answers1

1

The problem is about width and height of the view. As I understood, the view uses some value that is equal to zero while launching to draw the circle. But it really needed to use the other value (that calculates later).

This is reather popular problem: onCreate .. onPause methods do not know its own sizes and window sizes.

Solution: is to create your own observer that execute some code after the activity will know its sizes.

Here you know read wonder samples to fix similar issues. https://stackoverflow.com/a/24035591/1979882

Community
  • 1
  • 1
Vyacheslav
  • 26,359
  • 19
  • 112
  • 194
  • Thank you very much for this, When I used the view in activity everything worked fine, but when using it with dialog box the problem remained... – wael ben hamda Dec 06 '16 at 18:44