我想用动画列表来动画化字符串数组,有没有办法创建一个字符串列表,并将其添加到drawables中的动画-list.xml?
iv_randomize.setBackgroundResource(R.drawable.randomize_image);
AnimationDrawable frameAnimation2 = (AnimationDrawable) tv_randomize.getBackground();
frameAnimation.start();如果这是不允许的,那么最简单的方法是什么。谢谢:))
发布于 2015-12-06 20:01:59
你不能用动画列表做到这一点。
您可以改用下面的代码:
TextView mText = (TextView)findViewById(R.id.your_text_view);
String[] animationStrings = new String[]{"first text", "second text", "third text"};
float maxValue = animationStrings.length + 1;
final Animation textAnimation = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
int index = (int) Math.floor(maxValue * interpolatedTime);
index = index == maxValue ? index - 1 : index;
mText.setText(animationStrings[index]);
}
};
//set all the things you need to set on the textAnimation object
mText.startAnimation(textAnimation);(我只是写在我的头顶上-没有检查-所以你可能需要修改一下)
https://stackoverflow.com/questions/34117060
复制相似问题