顺时针旋转ImageView和逆时针旋转

时间:2018-02-28 11:15:23

标签: android

我创建了一个imageView,并希望根据按下的clockwise来轮换anti-clockwisebutton。每当我按下clockwise or anti-clockwise buttonimageView都不会旋转。如果我按下不是buttonclockwise的{​​{1}},则只会发生轮播。你会如何解决这个问题并立即进行轮换?

activity_negative.xml

anti-clockwise

activity_circle.xml

 <ImageView
  android:layout_width="170dp"
  android:layout_height="120dp"
  android:layout_gravity="center"
  android:id="@+id/imgCircle"
  android:src="@drawable/ic_circle"
  android:clickable="false"/>

image_rotate_clockwise

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid
    android:color="#666666"/>

<size
    android:width="120dp"
    android:height="120dp" />

</shape>

image_rotate_anticlockwise

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
 android:duration="1000"
 android:repeatCount="infinite"
 android:fromDegrees="0"
 android:interpolator="@android:anim/linear_interpolator"
 android:pivotX="50%"
 android:pivotY="50%"
 android:toDegrees="360" />

NegativeActivity.java

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:repeatCount="infinite"
android:fromDegrees="360"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="0" />

由于

0 个答案:

没有答案