android - getLocationOnScreen returns old position after rotation -


what have:

  • an activity android:configchanges="orientation|screensize|keyboardhidden"
  • a dialogfragment on it
  • viewa on dialogfragment

what's problem:

i'm using viewa.getlocationonscreen location on screen of view. when first open dialog position correct. after rotate screen, because of android:configchanges view somehow doesn't update it's position , if dialog correctly centered in activity getlocationonscreen of viewa points older location, before rotation.

what i've tried.

i overrode onconfigurationchanged of dialog , tried this:

  • viewa.requestlayout (doesn't anything)
  • viewa.getviewtreeobserver().addongloballayoutlistener , on ongloballayout set topmargin 1 , call requestlayout again. (this worked don't want set margin every time rotate screen)

what want know how can force reposition of dialog, making getlocationonscreen return correct values after rotation

note don't want change android:configchanges

to try explain, if have android:configchanges="orientation no recreation of activity take place, means views not measured, why old positions being reported, request full draw on view need o call on dialogframent's view parent overall game decorview- call invalidate() & requestlayout()


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -