100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > android应用的loading加载动画制作

android应用的loading加载动画制作

时间:2019-12-03 19:17:33

相关推荐

android应用的loading加载动画制作

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。