使用 xml 制作 android 启动画面动画

make android splash screen animation with xml

我想在 android 中制作与测验相关的动画启动画面。任何人都可以帮助我制作启动画面,为我的测验应用程序提供良好的开端吗?

虽然您没有具体说明想要的动画类型,但我只会将此答案限制为 Android 动画 class 中的选项。

android中的Animation(http://developer.android.com/reference/android/view/animation/Animation.html)class基本分为AlphaAnimation、RotateAnimation、ScaleAnimation、TranslateAnimation四种。每个人都操纵一种特定类型的对象 属性.

AplahAmianation:控制对象的 alpha 级别的动画。用于淡入淡出。

RotateAnimation:控制物体旋转的动画

ScaleAnimation:控制对象缩放的动画。您可以指定用于缩放中心的点。

TranslateAnimation:控制对象位置的动画

你也可以使用 AnimationsSet 来表示一组应该一起播放的动画。

我将使用其中一个属性作为示例,然后您可以从那里获取它。

AlphaAnimation alpha;
TextView splashText, splashText2;
Handler handler;
Runnable runnable = new Runnable() {

    @Override
    public void run() {
        splashText2.setVisibility(1);
        splashText2.setText(splashText2.getText().toString() + ".");

    }
};



    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_splash_screen);

    alpha= new AlphaAnimation(0, 1);
    alpha.setDuration(1000);
    handler = new Handler();


    splashText = (TextView)findViewById(R.id.slash_test);

Thread myTread = new Thread(){
        public void run() {
        try {
            sleep(1500);
            handler.post(runnable);
            sleep(500);
            handler.post(runnable);
            sleep(500); 
            handler.post(runnable);
            sleep(500); 
            handler.post(runnable);

            Intent changeActivity = new Intent(SplashScreen.this, WelcomeScreen.class);
            startActivity(changeActivity);


        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        finally{
              finish();
        }


        };
            };
       myTread.start();
       splashText.setAnimation(alpha);

    }

这将创建一个 splascreen,使文本淡入并持续加载动画... 行

splashText2.setVisibility(1);

会将可见度从 0 更改为 1