Java 在文本视图框周围显示旋转箭头

Java 在文本视图框周围显示旋转箭头,java,android,Java,Android,如何制作围绕文本旋转的动画。文本必须保持不变,它只会围绕边缘旋转。有一个物体朝箭头方向旋转 您的需求是文本视图的顺时针动画 [1] 。按照下面的代码设计XML <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/t

如何制作围绕文本旋转的动画。文本必须保持不变,它只会围绕边缘旋转。有一个物体朝箭头方向旋转


您的需求是文本视图的顺时针动画

[1] 。按照下面的代码设计XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <RelativeLayout
        android:layout_marginTop="40dp"
        android:id="@+id/relative"
        android:padding="50dp"
        android:layout_width="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="40dp"
            android:text="Hello Rotate Me!"
            android:gravity="center"
            android:layout_centerInParent="true"/>

        <TextView
            android:layout_width="120dp"
            android:layout_margin="10dp"
            android:layout_height="wrap_content"
            android:id="@+id/tvRotation"
            android:layout_centerInParent="true"
            android:padding="10dp"
            android:background="@drawable/back_txt"/>


    </RelativeLayout>

    <Button
        android:layout_marginTop="20dp"
        android:id="@+id/btnStart"
        android:layout_width="80dp"
        android:background="#000000"
        android:layout_height="50dp"
        android:text="start"
        android:textColor="#ffffff"/>


</LinearLayout>
[4] 。背景可根据需要绘制,但我的可绘制文件代码为back\u txt

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke android:color="#0000ff" android:width="2dp"/>

</shape>

TextView edtRotation=findViewById(R.id.YOUR_TEXTVIEW_ID);
Animation aniRotate = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.clockwise);
edtRotation.startAnimation(aniRotate);
<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke android:color="#0000ff" android:width="2dp"/>

</shape>