懒人必备---Android动画开源组件--EasyAndroidAnimations

这篇文章先介绍一下EasyAndroidAnimations,后续使用慢慢跟上。GitHub地址:https://github.com/2359media/EasyAndroidAnimations

为什么说这个是懒人必备哪?我本人对动画是非常无感,最愁各种效果,各种动画。今天看到了这个库,不敢独享,特此简单介绍一下。

这个随便写一个例子吧,先上布局文件activity_anim:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
<span style="white-space:pre">	android:background="#f00f02"</span>>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:src="@drawable/ic_launcher"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />
<span style="white-space:pre">	</span><Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="开始动画"
        android:id="@+id/btn_start_anim"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />
</RelativeLayout>
由于我用的Android-Studio,所以先导一下包,在build.gradle中:

 compile files('libs/easyandroidanimationslibrary-v0.5.jar')
前期准备工作完成,下边展示一下怎么用,我们先用个简单的动画效果,在Activity中:

   ImageView imgView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_anim);

        imgView = (ImageView) findViewById(R.id.img_view);

        new BounceAnimation(imgView).animate();

    }
然后看看效果:

第一次用录屏工具,大家凑活看。下边看看比较复杂的实现:

 <span style="white-space:pre">	</span>new BounceAnimation(imgView)
                        .setBounceDistance(1000)
                        .setNumOfBounces(4)
                        .setDuration(100)
                        .setListener(new AnimationListener(){

                            @Override
                            public void onAnimationEnd(Animation animation) {
                                Toast.makeText(getApplicationContext(),"End",Toast.LENGTH_SHORT).show();
                            }
                        }).animate();
看一下结果:

只有第一次点击的时候录上了效果,这个录屏工具真心不好用!

好吧所有的先介绍到这里!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值