我正在使用textview通过以下代码
来改变他的位置 tvPostText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
scaleGestureDetector.onTouchEvent(event);
if (event.getPointerCount() == 3) {
tvPostText.setRotation(rotation(event));
} else if (event.getPointerCount() == 1) {
if (event.getAction() == MotionEvent.ACTION_MOVE) {
v.setX(event.getRawX() - v.getWidth() / 2.0f);
v.setY(event.getRawY() - v.getHeight() / 2.0f);
}
}
return true;
}
我在它上面应用了旋转动画。如果我通过手指触摸更改textview的位置,则动画无法正常工作。有人可以告诉我,即使更改了textview Position,我怎样才能在textview上应用动画。
以下是动画代码: -
RotateAnimation anim = new RotateAnimation(0.0f, 360.0f , Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(3000);
tvPostText.startAnimation(animRotate);
答案 0 :(得分:1)
动画完成后,尝试在textview上调用clearAnimation()
。它帮助了我。
答案 1 :(得分:1)
使用Animator
<Style TargetType="{x:Type ContextMenu}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border BorderThickness="1" CornerRadius="4" BorderBrush="Black" x:Name="Border" Background="White">
<StackPanel ClipToBounds="True" Orientation="Vertical" IsItemsHost="True" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Background" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>