【问题标题】:make android splash screen animation with xml用xml制作android闪屏动画
【发布时间】:2015-07-12 15:53:27
【问题描述】:

我想在 android 中制作一个与测验相关的动画闪屏。谁能帮我制作启动画面,为我的测验应用提供良好的开端?

【问题讨论】:

标签: android android-animation splash-screen


【解决方案1】:

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

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

AplahAmiation:控制对象 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

【讨论】:

  • 感谢您的回复,我需要一个在 android 中带有 xml 的动画屏幕,我想要一个与测验相关的闪屏示例或为问答游戏制作动画屏幕的想法我需要一个想法,我需要什么可以为问答游戏的启动画面做什么是指我可以包含的内容,使其看起来很有吸引力,谢谢您的回复
猜你喜欢
  • 1970-01-01
  • 2021-10-17
  • 1970-01-01
  • 2020-08-30
  • 2019-12-26
  • 2022-01-26
  • 1970-01-01
  • 1970-01-01
  • 2012-03-12
相关资源
最近更新 更多