您的位置:首页 > 移动开发 > Android开发

【Android】应用的loading加载动画制作

2014-03-20 09:44 411 查看
加载界面只需要一张logo,颜色渐深,三秒显示后跳入下一个activity,同时去掉标题栏与状态栏。代码如下:AppLoadingActivity.java中
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44


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:
1
2
3
4
5
6
7
8
9
10
11
12
13


<?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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


<?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>


声明:eoe文章著作权属于作者,受法律保护,转载时请务必以超链接形式附带如下信息

原文作者: qwer20042127

原文地址: http://my.eoe.cn/1169143/archive/24089.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 动画 界面