Exiting fullscreen activity sometimes leaves artifacts in action bar and system navigation areas

 ̄綄美尐妖づ 提交于 2019-12-25 02:56:03

问题


I have a normal Activity (A) with visible Action Bar which launches another fullscreen activity (B) to display photos. When (B) finishes and activity (A) is displayed back sometimes I can see the following picture:

Please note visual distortion of action bar and navigation areas. The above artifacts disappear only when I start interacting with the activity, scrolling it, etc.

Full screen activity code:

protected void onCreate(Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    super.onCreate(savedInstanceState);

    ActionBar supportActionBar = getSupportActionBar();
    supportActionBar.hide();
}
  1. No hints in AndroidManifest.xml are used.
  2. Support libraries are used (appcompat)
  3. Reproduced on Nexus 4, Android 5.0.1

The only style customization that I have:

 <style name="Theme.MyApp" parent="@style/Theme.AppCompat" tools:ignore="NewApi">
    <!-- Text appearance -->
    <item name="android:textColorLink">@color/linkColor</item>
</style>

Does anybody know any clues why is that ?


回答1:


It is a bug on Lollipop Nexus devices. As workaround it would be possible to disable hardware acceleration on manifest activity's declaration: android:hardwareAccelerated="false" (this slows graphic performances).




回答2:


I got the same thing with my application. However, the folowing thing seem to fix that up (at list for me):

 @Override
protected void onResume() {
    super.onResume();

    findViewById(R.id.root).setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            findViewById(R.id.root).setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }
    }, 500);
}

As you can see - I'm trying to switch off Hardware acceleration and than switch it on again for my main root view in the layout. I don't actully know why changing view type worked because that's what you can find on HA Thread:

Note: You currently cannot enable hardware acceleration at the view level. View layers have other functions besides disabling hardware acceleration. See View layers for more information about their uses.



来源:https://stackoverflow.com/questions/29509846/exiting-fullscreen-activity-sometimes-leaves-artifacts-in-action-bar-and-system

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