Android 平移动画+缩放动画=集合动画->实现开机启动页+通过线程休眠事件跳转到主界面

<pre name="code" class="java">WelcomeActivity:
package demo.lxiangjian.com.ten;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class WelcomeActivity extends AppCompatActivity {

    private ImageView imageView;
    private Animation an;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        imageView = (ImageView) findViewById(R.id.imgView);
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    an = AnimationUtils.loadAnimation(WelcomeActivity.this, R.anim.set_animaition);
                    //开启动画
                    imageView.startAnimation(an);
                    Thread.sleep(4000);
                    Intent intent =new Intent();
                    intent.setClass(WelcomeActivity.this,MainActivity.class);
                    startActivity(intent);
                    finish();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();
    }
}
 
activity_welcome.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/my_collect_article"
  >
    <ImageView
        android:id="@+id/imgView"
        android:background="@drawable/start_bg"
        android:scaleType="fitXY"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="40dp">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@mipmap/welcome_logo"
            android:layout_centerVertical="true"
            android:layout_centerInParent="true"
            android:layout_marginBottom="30dp"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/white"
            android:textSize="15sp"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            android:text="半杯咖啡工作室"/>
    </RelativeLayout>

</RelativeLayout>



res->anim->set_animtion.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <scale xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="100"
        android:fillAfter="false"
        android:fromXScale="0.0"
        android:fromYScale="0.0"
        android:pivotX="100%"
        android:pivotY="100%"
        android:toXScale="1.2"
        android:toYScale="1.0"
        />

    <!--    
    fromXDelta,fromYDelta       起始时X,Y座标,屏幕右下角的座标是X:320,Y:480   
    toXDelta, toYDelta      动画结束时X,Y的座标 --> <!--    
    interpolator                    指定动画插入器  
    常见的有加速减速插入器         accelerate_decelerate_interpolator  
    加速插入器               accelerate_interpolator,  
    减速插入器               decelerate_interpolator。   
    fromXScale,fromYScale,         动画开始前X,Y的缩放,0.0为不显示,  1.0为正常大小  
    toXScale,toYScale,          动画最终缩放的倍数, 1.0为正常大小,大于1.0放大  
    pivotX,  pivotY         动画起始位置,相对于屏幕的百分比,两个都为50%表示动画从屏幕中间开始   
    startOffset,                动画多次执行的间隔时间,如果只执行一次,执行前会暂停这段时间,  
                        单位毫秒 duration,一次动画效果消耗的时间,单位毫秒,  
                        值越小动画速度越快 repeatCount,动画重复的计数,动画将会执行该值+1次   
                        repeatMode,动画重复的模式,reverse为反向,当第偶次执行时,动画方向会相反。  
                        restart为重新执行,方向不变 -->
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromXDelta="120"
        android:toXDelta="0"
        android:fromYDelta="1.0"
        android:toYDelta="1.0"
        android:duration="4000"
        />
    <!--
      fromXDelta,fromYDelta   起始时X,Y座标,屏幕右下角的座标是X:320,Y:480
      toXDelta, toYDelta     动画结束时X,Y的座标 -->
</set>



                
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奋斗年轻人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值