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

来源:互联网 发布:免费php人才招聘系统 编辑:程序博客网 时间:2024/05/01 06:13

加载界面只需要一张logo,颜色渐深,三秒显示后跳入下一个activity,同时去掉标题栏与状态栏。代码如下:AppLoadingActivity.java中

 1 2 3 4 5 6 7 8 91011121314151617181920212223242526272829303132333435363738394041424344
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 910111213
<?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 91011121314151617181920212223
<?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
原创粉丝点击