android 设置动画时间,如何以特定的时间间隔为图片添加动画效果?

问:StacyM

在Android的开发过程中,我用的是Coursera类别,以下是我想要实现的静态效果图:

目前,我采用的代码是:

XML:

android:id="@+id/startbutton"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_above="@+id/leftfoot"

android:layout_alignRight="@+id/leftfoot"

android:onClick="startRhythmandAnimation"

android:text="@string/start_button" />

Java:

public class Assignment3MainActivity extends Activity {

private View mMileTimeGoal;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_assignment3_main);

mMileTimeGoal = findViewById(R.id.miletimegoal);

}

public void startRhythmandAnimation () {

String MileTime = mMileTimeGoal.getContext().toString();

String[] time_array = MileTime.split(":");

int hours = Integer.parseInt(time_array[0]);

int minutes = Integer.parseInt(time_array[1]);

int seconds = Integer.parseInt(time_array[2]);

int duration = 3600 * hours + 60 * minutes + seconds;

int steps_per_second = 3;

int running_rate = duration * steps_per_second;

View rightfoot = findViewById(R.id.rightfoot);

View leftfoot = findViewById(R.id.leftfoot);

rightfoot.setVisibility(View.VISIBLE);

Animation anim = AnimationUtils.makeInChildBottomAnimation(this);

rightfoot.startAnimation(anim);

leftfoot.setVisibility(View.VISIBLE);

leftfoot.startAnimation(anim);

}

我应该采用什么算法,来完成左、右脚的淡入淡出的“运动”呢?需要设定一种循环运动的定时器吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值