java如何避免webview 安卓应用程序上出现白色屏幕
活动_main
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
tools:context="com.google.httpwww.google.MainActivity">
<WebView
安卓:id="@+id/webView"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:layout_centerHorizontal="true"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" />
</RelativeLayout>
主要活动。java
package com.google.httpwww.google;
import 安卓.support.annotation.Nullable;
import 安卓.support.v7.app.AppCompatActivity;
import 安卓.webkit.WebSettings;
import 安卓.webkit.WebView;
import 安卓.os.Bundle;
import 安卓.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
WebView webview;
@Override
public void onBackPressed() {
if (webview.canGoBack()) {
webview.goBack();
} else {
super.onBackPressed();
}
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webview = (WebView) findViewById(R.id.webView);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl("http://www.google.com/");
}
}
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
package="com.google.httpwww.google">
<uses-permission 安卓:name="安卓.permission.INTERNET"/>
<application
安卓:allowBackup="true"
安卓:icon="@mipmap/ic_launcher"
安卓:label="@string/app_name"
安卓:roundIcon="@mipmap/ic_launcher_round"
安卓:supportsRtl="true"
安卓:theme="@style/AppTheme">
<activity 安卓:name=".MainActivity">
<intent-filter>
<action 安卓:name="安卓.intent.action.MAIN" />
<category 安卓:name="安卓.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
当我运行应用程序时,它会给出一个白色的空白页面,标题是应用程序的名称。在互联网上,大多数案例都是基于应用程序的一开始,有一个白色页面,但在我的案例中,它仍然存在。你知道我做错了什么吗
附言:我对安卓应用程序很陌生,我只需要一个能显示我网站的应用程序
共 (0) 个答案