水平图像旋转

时间:2013-12-29 11:44:40

标签: android animation rotation

我有动画,图片顺时针旋转(垂直空间)。反过来,我需要在水平空间中旋转图片。

我的垂直旋转示例,请横向旋转帮助:

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

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

</set>

1 个答案:

答案 0 :(得分:1)

在资源 - &gt;创建任意名称的anim文件夹 - &gt; xml文件

     <set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
  <scale
            android:fromXScale=".3"
            android:toXScale="1.0"
            android:fromYScale="0.3"
            android:toYScale="1.0"
            android:pivotX="50%"
            android:pivotY="50%"
            android:duration="800" />

        <rotate
            android:fromDegrees="0"
            android:toDegrees="180"

            android:pivotX="50%"
            android:pivotY="50%"
            android:duration="800" />

</set>

现在你可以随时随地使用这个动画

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.[yourlayout]);

    findViewById(R.id.outer).startAnimation(AnimationUtils.loadAnimation(this,R.anim.your_file_nmae));

}