android中利用animation实现Image的循环移动

本文介绍了如何在Android中使用TranslateAnimation创建图片移动的动画效果,并通过设置AnimationListener实现在动画结束时无缝循环移动。作者通过对比,指出此方法类似于制作PPT,并提供了布局文件和Java代码示例,鼓励读者尝试并提出改进建议。
摘要由CSDN通过智能技术生成

本文利用TranslateAnimation实现图片的移动动画效果,利用setAnimationListener实现图片的循环移动!

思想很简单,就是在第一个动画结束的时候开始下一个动画。做这个的过程让我感觉很像是在做ppt。

现在感觉很多东西原理真的都是相通的。


首先是设置四个动画效果,利用TranlateAnimation,然后在每个animation的setAnimationListener中启动下一个动画效果。


效果图片如下:



布局文件如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <RelativeLayout
        android:id="@+id/newIcon"
        android:layout_centerInParent="true"
        android:layout_width="match_parent"
        android:layout_height="80dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="20dp"
            android:orientation="horizontal">

            <RelativeLayout
                android:id="@+id/dynamicView"
                android:layout_marginTop="10dp"
                android:layout_width="60dp"
                android:layout_height=
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值