描述:點(diǎn)擊播放按鈕后,只能聽到聲音,而畫面是白的….一直白…想到應(yīng)該是硬件加速的問題
1.確認(rèn)硬件加速(非此因素)
在WebViewActivity.java中發(fā)現(xiàn)
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
2.確認(rèn)AndroidManifest.xml(非此因素)
application節(jié)點(diǎn)下并沒有發(fā)現(xiàn)
android:hardwareAccelerated="true"
在WebViewActivity中,也無該配置
-
嘗試: WebViewActivity.java中,注釋
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
在AndroidManifest.xml節(jié)點(diǎn)下加入android:hardwareAccelerated="true"
- 結(jié)果…...沒用
3.檢查activity_web_view.xml
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:visibility="@{showError?View.GONE:View.VISIBLE}" />
沒問題.
BUT….
<LinearLayout
android:layerType="software"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/layout_toolbar" />
<ProgressBar
android:id="@+id/web_load_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="2dp"
android:indeterminateOnly="false"
android:max="100"
android:progress="@{progress}"
android:progressDrawable="@drawable/progress_bar_states"
android:visibility="gone" />
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:visibility="@{showError?View.GONE:View.VISIBLE}" />
</LinearLayout>
父布局竟然android:layerType="software"
- 解決,刪掉該屬性即可