问题
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();
}
- No hints in AndroidManifest.xml are used.
- Support libraries are used (appcompat)
- 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