如何创建这样的动画启动画面
How to create Animated Splash Screen such this
我需要制作这样的动画启动画面。你能帮帮我吗?
您可以像这样使用 gif 图像并在初始屏幕上使用它而不是普通的 jpg 或 png 图像
一种方法是像下面这样使用补间动画。在你的情况下需要多个 anim
文件
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation);
比如说,如果您必须为白色圆圈图像制作动画,那么请执行以下操作
ImageView image = (ImageView)findViewById(R.id.imageView);
Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move);
image.startAnimation(animation1);
现在您需要在 res/anim/move.xml
中创建动画文件
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromXDelta="0%p"
android:toXDelta="75%p"
android:duration="800" />
</set>
这是一个例子。您需要找到根据您的要求修改这些基本动画的方法。更多参考 this link
为启动画面使用 gif。
在您的 build.gradle 文件中:
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
在您的活动布局中:
<pl.droidsonroids.gif.GifImageView
android:id="@+id/gifView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/gif"
/>
最后在您的 class 文件中:
private static int SPLASH_TIME_OUT = 1500;
private boolean isInFront;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_gif);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This method will be executed once the timer is over
if(isInFront)
{
// Start your app main activity
Intent i = new Intent(SplashScreen_Gif.this, MainMenuActivity.class);
startActivity(i);
}
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
我需要制作这样的动画启动画面。你能帮帮我吗?
您可以像这样使用 gif 图像并在初始屏幕上使用它而不是普通的 jpg 或 png 图像
一种方法是像下面这样使用补间动画。在你的情况下需要多个 anim
文件
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation);
比如说,如果您必须为白色圆圈图像制作动画,那么请执行以下操作
ImageView image = (ImageView)findViewById(R.id.imageView);
Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move);
image.startAnimation(animation1);
现在您需要在 res/anim/move.xml
中创建动画文件<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromXDelta="0%p"
android:toXDelta="75%p"
android:duration="800" />
</set>
这是一个例子。您需要找到根据您的要求修改这些基本动画的方法。更多参考 this link
为启动画面使用 gif。 在您的 build.gradle 文件中:
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
在您的活动布局中:
<pl.droidsonroids.gif.GifImageView
android:id="@+id/gifView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/gif"
/>
最后在您的 class 文件中:
private static int SPLASH_TIME_OUT = 1500;
private boolean isInFront;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_gif);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This method will be executed once the timer is over
if(isInFront)
{
// Start your app main activity
Intent i = new Intent(SplashScreen_Gif.this, MainMenuActivity.class);
startActivity(i);
}
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}