为了效果好看,自定义view来实现。先来看效果图
使用起来很简单,在xml中使用view,在activity中调用属性动画即可:
mSbv.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
int width = mSbv.getWidth();
Log.e("getWidth",width+"____");
ObjectAnimator animator = ObjectAnimator.ofFloat(mSbv, "moveX", 0 ,-width*2);
animator.setDuration(7 * 1000);
animator.setInterpolator(new LinearInterpolator());
animator.setRepeatCount(-1);
animator.start();
}
});
https://github.com/Luffy0317/ColorfulText