我想编写一个 ImageView 先缓慢旋转然后逐渐增加旋转速度的程序

I want to program an ImageView to first rotate slowly and then gradulaly increase the rotation speed

我正在使用具有粉丝图像的 ImageView。布局资源文件是这样的:

XML 布局代码:

<ImageView
android:layout_width="200dp"
android:layout_height="250dp"
android:layout_gravity="center"
android:src="@drawable/f786"
android:id="@+id/imggif"
tools:ignore="ContentDescription" />

在我的 activity 中,我定义了 ImageView 并设置了 .animate().rotation() 方法。如下图:

我的MainActivity代码:

public class boostActivity extends AppCompatActivity {

private static int TIME_OUT = 4000;
private  ImageView iv;
private TextView txv;
private TextView mTextView;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.boost_now);

iv = (ImageView) findViewById(R.id.imggif);
txv= (TextView) findViewById(R.id.textView3);
mTextView = (TextView) findViewById(R.id.tv);

iv.animate().rotation(360).setDuration(2500);

但是扇形图像继续以同样的速度旋转。我希望它逐渐增加旋转。我也试过这个:

iv.animate().rotation(360).setDuration(3500).rotation(360).setDuration(1000)

但是没有用。

您确实希望使用 animationset,这使得链接动画成为可能。

一个例子:

    ObjectAnimator test1 = ObjectAnimator.ofFloat(view, "rotation", 0f, 360f);
    test1.setDuration(1000);

    ObjectAnimator test2 = ObjectAnimator.ofFloat(view, "rotation", 0f, 360f);
    test1.setDuration(500);

    AnimatorSet set = new AnimatorSet();
    set.playSequentially(test1, test2);
    set.start();