ImageView的旋转与XML不转 [英] ImageView with rotate xml not rotating

查看:108
本文介绍了ImageView的旋转与XML不转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下code,

<ImageView
        android:id="@+id/imgView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@drawable/animate"/>

我animate.xml是,

My animate.xml is,

<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">

和java中启动它,

ImageView imgView=(ImageView)findViewById(R.id.imgView);
              Animation rotation = AnimationUtils.loadAnimation(this, R.drawable.animate);
              imgView.startAnimation(rotation);

但仍然是我的ImageView不转动,
我见过很多例子,但没有人在工作。

But still my ImageView is not rotating, I have seen many examples, but none of them are working.

推荐答案

试试这个

    <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);

这篇关于ImageView的旋转与XML不转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆