[英]How do I make a animation splash screen?
如何制作 animation 启动画面?
我希望我的应用看起来更专业,所以我决定添加一个启动画面。 我应该如何实现 animation 启动画面?
首先,您应该创建一个名为“SplashScreen”的新 Activity。 然后根据需要修改 xml 文件(设计它)。
我想您想在应用程序打开时和有限的时间内显示该屏幕。
首先你必须在你的 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>
如您所见,您必须将“SplahScreen”活动放在“intent-filter”之前。
在您的 Splashscreen java 文件中,您应该编写如下内容:
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.