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

加载界面只需要一张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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值