2

我的应用程序有一个用于初始应用程序加载的旋转轮。在 android 3.0 蜂窝中工作正常。但在 ICS 4.0 中它被打破了。它是一个简单的旋转轮动画。在 ICS 中,这个轮子围绕其圆周附近的一个点而不是中心点旋转。这给人一种像摇摆不定的轮子而不是一致的旋转轮子的视觉印象。这是代码

布局:

<ImageView 
            android:id="@+id/spinner"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:src="@drawable/spinner_white_48"
            android:layout_centerHorizontal="true"
            android:layout_alignParentTop="true"
        />

spinner_animation.xml

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

    </rotate>

Java 文件(活动)

Animation rotateSpinner = AnimationUtils.loadAnimation(this,R.anim.spinner_animation);
rotateSpinner.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) { 
            } 
            @Override
            public void onAnimationRepeat(Animation animation) { 
            }
            @Override
            public void onAnimationEnd(Animation animation) {
            }
        }); 
 findViewById(R.id.spinner).startAnimation(rotateSpinner); 

注意:该应用程序甚至无法在 4.0.2(Samsung Galaxy)上启动。但是在 4.0.3 应用程序中显示这个扭曲的动画效果很好(Nexus S)。

任何帮助表示赞赏。提前致谢

4

4 回答 4

1

在有更好的修复之前,您可以使用:

RotateAnimation rotation;
if(Integer.parseInt(Build.VERSION.SDK) >=15){
    rotation = new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,0.25f,Animation.RELATIVE_TO_SELF,0.25f);
}else{
    rotation = new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
}
于 2012-02-27T07:14:36.283 回答
1

如果“摇摆”是指它似乎围绕其中心点以外的东西旋转,那么这是一个已知的错误

于 2012-01-05T19:52:59.923 回答
0

您应该在清单中添加以下内容:

<supports-screens android:resizeable="true"
                  android:smallScreens="true"
                  android:normalScreens="true"
                  android:largeScreens="true"
                  android:anyDensity="true"/>
于 2012-03-28T11:40:21.833 回答
0

检查布局设置。我有一种感觉,如果你只是将相同的视图放在一个简单的 LinearLayout 中,它会再次正常工作。看来您在 RelativeLayout 中,我感觉 layout_centerHorizo​​ntal 或 layout_alignParentTop 让您感到悲伤。

于 2012-01-31T22:27:50.223 回答