Android 5 screen glitch/static with Google Maps Fragment inside a Viewpager

◇◆丶佛笑我妖孽 提交于 2019-12-22 10:34:29

问题


I am having a strange issue related to Android 5 and Google Maps combined with a Viewpager and Fragments, hoping to get some good ideas from all of you..

Screenshot of the problem: http://postimg.org/image/6wzssbdbr/ (no rep for inlining yet)

Situation:

  • Main Activity with a Viewpager that has a number of Fragments
  • One of the Fragments has a MapView inside it with all lifecycle methods forwarded; replace MapView with MapsFragment and the issue is the same
  • Open a new Activity, as long as the new Activity is not using too much memory (I assume), the onDestroy of the Main Activity is not called and the glitch happens, if onDestroy is called, the glitch does not happen
  • That second Activity has an input field for a card number and when this Activity is opened, I see the screenshot above.

If I go back from the second Activity to the first I also get something strange, a bottom part of the screen is copied to the top and shown there with some static around it.

Devices with Android 4 don't have the problem, I am targeting the latest SDK, using the latest build tools.

If I remove the Fragment in the Viewpager with the Google Maps inside it, no issue.

The only thing that did work is android:hardwareAccelerated='false' but as you might imagine this slows down the app..

Any suggestions/ideas are welcome.. I tried around 4-5 different things so far and only android:hardwareAccelerated works.

Thanks for reading,

Danny

Edit:

(Not enough rep to post more than 2 links, so links below without the code.google.com in front of it) Google code issues:

  • My issue is reported here] -> /p/gmaps-api-issues/issues/detail?id=7391 because I thought it was maps specific

  • Similar issue found here -> /p/android/issues/detail?id=81832 reported in Android bugs

Stackoverflow similar issue: Android SystemUI glitches


回答1:


Add:

android:hardwareAccelerated="false"

to your Activity or Application manifest entry. This workaround disables hardware accelerated graphics, so don't take this lightly. There is at least one bug report into Google for similar visual glitches to yours, hopefully they get this resolved quickly.

I wouldn't recommend putting this into a shipping app, only to prove or disprove that your drawing glitches are due to problems with the underlying hardware acceleration system.

You can also try disabling hardware acceleration at the View level via:

view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

in particular if you have WebView's, setting layer type to software on WebView's in my app went a long way towards resolving UI glitches.



来源:https://stackoverflow.com/questions/27139494/android-5-screen-glitch-static-with-google-maps-fragment-inside-a-viewpager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!