简单ImageView的旋转 [英] Simple ImageView Rotation

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

问题描述

我使用此XML code来旋转imageVeiw 180度:

I am using this xml code to rotate an imageVeiw 180 degrees:

<ImageView
    android:id="@+id/keyP2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/btn4"
    android:layout_centerHorizontal="true"
    android:adjustViewBounds="true"
    android:rotation="180"
    android:maxWidth="125dp"
    android:scaleType="fitCenter"
    android:src="@drawable/image0_key" />

这为Android API版本11工作正常,并,但的android:旋转=180不支持低于API 11.我怎么能旋转的ImageView的180度低于11?

This works fine for android api version 11 and up, but android:rotation="180" is not supported below api 11. How can I rotate an imageView 180 degrees for below 11?

推荐答案

试试这个。它为我工作。

Try this one. it work for me.

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator" >

  <rotate
      android:duration="2000"
      android:fromDegrees="0"
      android:pivotX="50%"
      android:pivotY="50%"
      android:toDegrees="360" >
  </rotate>

</set>

保存资源文件名为文件夹下的动画。

Save this file in resources under a folder named "anim".

RES /动画/ rotate.xml

res/anim/rotate.xml

在您的活动。收藏此code。

Within your activity. Add this code.

    Animation sampleFadeAnimation = AnimationUtils.loadAnimation(PreviewImageActivity.this,R.anim.rotate);
    sampleFadeAnimation.setRepeatCount(1);
    yourImageView.startAnimation(sampleFadeAnimation);

做一些研究,你会得到很多的属性,以改善这个旋转动画作为你的愿望。

Do some research you will get lot of properties to improve this rotate animation as your wish.

感谢...

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

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