加载界面只需要一张logo,颜色渐深,三秒显示后跳入下一个activity,同时去掉标题栏与状态栏。
代码如下:AppLoadingActivity.java中
public class AppLoadingActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// 取消标题栏(也可以在manifest里面配置)
// this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// 取消状态栏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.app_loading);
// 三秒钟之后进入login
ImageView loadingIv = (ImageView) this.findViewById(R.id.logo_bg);
// 从浅到深,从百分之10到百分之百
AlphaAnimation animation = new AlphaAnimation(0.1f, 1.0f);
animation.setDuration(3000);
loadingIv.setAnimation(animation);
// 给animation设置监听器
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
// 三秒之后跳出
Intent it = new Intent(AppLoadingActivity.this, MainActivity.class);
startActivity(it);
// 三秒之后 这个窗口就没用了 应该finish
finish();
}
});
}
}
app_loading.xml:
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
>
<ImageView
android:id=”@+id/logo_bg”
android:background=”@drawable/app_loading”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
/>
</LinearLayout>
AppLoadingManifest.xml:
<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”com.android.aming.apploading”
android:versionCode=”1″
android:versionName=”1.0″>
<uses-sdk android:minSdkVersion=”7″ />
<application android:icon=”@drawable/icon” android:label=”@string/app_name”
//这个属性可以消除加载应用中间的黑屏
android:theme=”@android:style/Theme.Translucent”>
<activity android:name=”.AppLoadingActivity”
android:label=”@string/app_name”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
<activity android:name=”.MainActivity”>
</activity>
</application>
</manifest>