【发布时间】:2014-10-27 06:59:02
【问题描述】:
我是 Android 应用程序的新手,这是我的第一个应用程序。 我已经创建了启动画面并且可以工作..但是在它消失后大约 2-5 秒出现一个长长的白色空白屏幕然后 url 开始加载..
我的问题是.. 加载 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>
【问题讨论】:
标签: java android webview loading splash-screen