android webview 在3.0+後顯示flash要啟用硬件加速,開啟硬件加速是在manifest中加入: android:hardwareAccelerated="true"
但是開啟硬件加速後webview有可能會出現閃爍的問題,解決方法是在webview中設置:
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
這是把webview 中的硬件加速關閉。設置LAYER_TYPE_SOFTWARE後會把當前view轉為bitmap保存。這樣就不能開多個webview,否則會報out of memory。
解決方法是在webview中加入:
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
invalidate();
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
摘自 fhy_2008的專欄