I have a LinearLayout with a vertical orientation, within that layout I have three buttons (ImageButtons to be exact) and when the orientation changes (via an OrientationEventListener) I have them set to perform a rotation animation. The top and bottom buttons rotate perfectly, however the middle one does not. Its pivot point seems to be off.
Here is the layout of the animation:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="-90"
android:pivotX="50%"
android:pivotY="50%"
android:duration="500"/>
...and here is how I initiate the animation:
Animation rotate = AnimationUtils.loadAnimation(this.mContext, animResId);
rotate.setFillEnabled(true);
rotate.setFillAfter(true);
{...retrieve the each ImageButton then call startAnimation(rotate) on them...}
...and here is the layout for the component in my activity that is the LinearLayout for my menu:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/camera_menu"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/camera_preview"
android:layout_alignParentRight="true"
>
<ImageButton
android:id="@+id/camera_top_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:src="@drawable/placeholder"
android:scaleType="centerInside"
android:onClick="onTopButtonClick"
/>
<ImageButton
android:id="@+id/camera_action_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:src="@drawable/placeholder"
android:scaleType="centerInside"
android:onClick="onActionButtonClick"
/>
<ImageButton
android:id="@+id/camera_bottom_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:src="@drawable/placeholder"
android:scaleType="centerInside"
android:onClick="onBottomButtonClick"
/>
</LinearLayout>
Does anyone have an idea as to why the middle (action) button is not rotating around the correct pivot point?
One thing I have noticed is that after rotating, the middle button is aligned with the tops of the other two, smaller buttons (the top and bottom buttons).
Thanks in advance for any help!
Regards, celestialorb.