Solving Rendering Artifacts in Frame Buffer with W

2019-08-03 15:27发布

After upgrading Nexus 5 to Android 5.0, an activity with default focus on an EditText does not render correctly (EditText repeats down across the screen with grey dots in between and if you click again or dump the ViewHierarchy with UiAutomator, it will return to normal rendering).

(I would upload the image, but don't yet have reputation for images).

NOTE: This is ONLY after I have loaded a WebView within the application (though in a separate activity). The same screen renders correctly prior to loading the first WebView in the application.

NOTE: This is ONLY a problem on Android 5.0 and (so far) on Nexus 5. I do not have another 5.0 (non-nexus) device to try.

EDIT: This also happened on HTC One with Android 5.01.

NOTE: I have tried disabling hardware acceleration, modifying inputMode, and defaultFocus.

Has anyone seen or solved this problem?

enter image description here

3条回答
混吃等死
2楼-- · 2019-08-03 15:35

Ended up solving this by changing softInputMode (similar to previous WebView/Keyboard issues, but this time with a native View and EditText).

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
查看更多
做个烂人
3楼-- · 2019-08-03 15:36

What solved my problem was to disable the hardware acceleration only on the activity which hosted my fragment. Not on the whole app, but specifically on that activity.

查看更多
来,给爷笑一个
4楼-- · 2019-08-03 15:38

I had a similar issue on Lollipop 5.0.1 devices. My solution was to deactivate hardware acceleration in the WebView on these devices before loading any content with loadURL or loadData.

int SDKversion = android.os.Build.VERSION.SDK_INT;
if(SDKversion >= android.os.Build.VERSION_CODES.LOLLIPOP){
    webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

If you do not want to do this, I could also drastically reduce the problem by adding a visibility="gone" webview to the disturbed activities and then calling something like:

webview_dummy.loadData("<head></head><body></body>", "text/html", "utf8");

after the loadURL of the actual webview. Man, this is really some weird bug!

查看更多
登录 后发表回答