【发布时间】:2017-10-26 07:20:37
【问题描述】:
我有绘图视图。这是一个用户可以签名的地方。当用户单击按钮时,我想制作某种扫描仪效果 - 绘制视图背景将从左侧更改为右侧(扫描的“进度”)。现在我创建了一个动画,但它一次改变了整个背景。我需要使它线性 - 从左到右。知道如何达到这种效果吗? :)
我的观点:
<com.rm.freedrawview.FreeDrawView
android:id="@+id/draw_layout"
android:layout_width="400dp"
android:layout_height="200dp"
android:background="@drawable/border_background"
app:paintAlpha="255"
app:paintColor="@color/black"
app:paintWidth="2dp"
app:resizeBehaviour="crop"
android:layout_centerHorizontal="true"
android:layout_marginTop="400dp"/>
这是我的动画:
@OnClick(R.id.next_button)
public void openActivity(){
int colorFrom = getResources().getColor(R.color.red);
int colorTo = getResources().getColor(R.color.black);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
colorAnimation.setDuration(1000);
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
mDraw.setBackgroundColor((int) animator.getAnimatedValue());
}
});
colorAnimation.start();
}
【问题讨论】:
-
你可以使用属性动画或翻译动画。
-
是属性动画师。只是我不知道如何实现线性效果