如何制作动画启动屏幕



如何制作动画启动屏幕?

我希望我的应用程序看起来更专业,所以我决定添加一个启动屏幕。我应该如何实现动画启动屏幕?

首先,您应该创建一个名为"的新活动;SplashScreen";。然后根据需要修改xml文件(设计它(。

我想你想在应用程序打开时在有限的时间内显示该屏幕。

Soy首先你必须更改AndroidManifest文件中的优先级屏幕。看看这个代码:

<application
...
<activity android:name=".MainActivity"></activity>
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>

正如你所看到的,你必须把你的";"飞溅屏幕";就在";意图过滤器";。

在你的SplashscreenJava文件中,你应该写这样的东西:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class SplashScreen extends AppCompatActivity {
/** Duration of splash in milliseconds**/
private final int SPLASH_DISPLAY = 1000;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
/* Start the Menu-Activity 
* and close Splash-Screen after SPLAH_DISPLAY milliseconds*/
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(SplashScreen.this,MainActivity.class);
Splash.this.startActivity(mainIntent);
Splash.this.finish();
}
}, SPLASH_DISPLAY);
}
}
It just simple 
add this anmiation in image view ,textview and etc...
ImageView image = (ImageView)findViewById(R.id.imageView);
Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), 
R.anim.clockwise);
image.startAnimation(animation1);

and this clockwise desgin class have te code that is
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000" >
</rotate>

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:startOffset="5000"
android:fromDegrees="360"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000" >
</rotate>

</set>

最新更新