我是Android應用程序中的新手,這是我的第一個應用程序。 我已經創建了啓動畫面和工程..但其後走了一個長長的白色空白屏幕約2-5秒,然後URL開始加載..Android Webview:加載url時出現閃屏
而我的問題是..如何使一些加載或進度加載網址時在啓動畫面中顯示吧?所以沒有更多的白色黑屏。對不起,我的英語不好。
的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.xxx" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="xxx"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true" />
<activity
android:name="com.xxx.xxx.Splash"
android:label="xxx"
android:theme="@style/Theme.MyAppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MyActivity"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenSize"
android:label="xxx" >
</activity>
</application>
</manifest>
activity_my.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MyActivity">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView"
android:layout_gravity="center"
/>
<TextView
android:id="@+id/display"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
/>
<FrameLayout
android:id="@+id/customViewContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"/>
</LinearLayout>
Splash.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
final Handler handel = new Handler();
handel.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Intent loadSplash = new Intent(Splash.this, MyActivity.class);
startActivity(loadSplash);
finish();
}
}, 3000);
}
}
splashscreen.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/splash" />
</RelativeLayout>
[初始屏幕而在Android應用一個網頁視圖加載URL](HTTP的可能的複製:// stackoverflow.com/questions/9589365/splash-screen-while-loading-a-url-in-a-webview-in-android-app) – 2016-03-26 20:56:12