用webview加載url出現空白頁,測試後把百度,Github之類的url傳進去都沒問題,後來發現是因爲佈局的原因,因爲webview對不同的網站兼容性沒有那麼強,特別是現在出現的各種前端佈局,沒法一一適應,在寫webview佈局的時候這樣寫:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>