我有 TextView 正在旋转,但我只想旋转 TextView 的背景而不是文本,我试图将 TextView 放在 LinearLayout 中,但它仍然随着文本旋转,那么我该如何解决这个问题?
我的xml代码如下:
<TextView
android:id="@+id/txtRotate"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignBottom="@+id/gif1"
android:layout_centerHorizontal="true"
android:background="@drawable/round_image"
android:text="Hello"
android:textColor="@android:color/holo_red_dark"
android:gravity="center" />
MainActivity.java
animFadein = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.rotate);
animFadein.setFillAfter(true);
animFadein.setAnimationListener(this);
txtVibrate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
txtRotate.startAnimation(animFadein);
}
});
旋转.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="6000"
android:repeatMode="restart"
android:repeatCount="0"
android:interpolator="@android:anim/cycle_interpolator"/>
</set>