Question

My application has a spinning wheel for the initial app load. Works fine upto android 3.0 honeycomb. But in ICS 4.0 its broken. Its a simple spinning wheel animation. In ICS this wheel is spinning around a point near its circumference instead of the center point. This gives a visual impression like a wobbling wheel instead of a consistent spinning wheel. Here is the code

Layout:

<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 File (Activity)

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

NOTE: The app wont even start on 4.0.2(Samsung Galaxy). But shows this distorted animation in 4.0.3 app app works fine(Nexus S).

Any help is appreciated. Thanks in advance

No correct solution

OTHER TIPS

If by "wobbling" you mean that it appears to be revolving around something other than its center point, then this is a known bug.

Until there is a better fix, you can use:

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

Check the layout settings. I have a feeling if you just drop the same view in a simple LinearLayout, it will work OK again. It appears you're in a RelativeLayout and I have a feeling the layout_centerHorizontal or layout_alignParentTop are giving you grief.

You should to add in your manifest this:

<supports-screens android:resizeable="true"
                  android:smallScreens="true"
                  android:normalScreens="true"
                  android:largeScreens="true"
                  android:anyDensity="true"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top