我正在使用以下代码,
<ImageView
android:id="@+id/imgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/animate"/>
Run Code Online (Sandbox Code Playgroud)
我的animate.xml是,
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="90"
android:toDegrees="90"
android:repeatCount="infinite"
android:drawable="@drawable/cameras">
Run Code Online (Sandbox Code Playgroud)
并在java中启动它,
ImageView imgView=(ImageView)findViewById(R.id.imgView);
Animation rotation = AnimationUtils.loadAnimation(this, R.drawable.animate);
imgView.startAnimation(rotation);
Run Code Online (Sandbox Code Playgroud)
但是我的ImageView仍然没有旋转,我看过很多例子,但是没有一个能够正常工作.
试试这个
<ImageView
android:id="@+id/imgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/animate"/>
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="359"
android:duration="1000" >
</rotate>
ImageView imgView=(ImageView)findViewById(R.id.imgView);
Animation rotation = AnimationUtils.loadAnimation(this, R.drawable.animate);
imgView.startAnimation(rotation);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
606 次 |
| 最近记录: |