I have a LinearLayout with a vertical orientation, inside this layout I have three buttons (more precisely, ImageButtons), and when the orientation changes (via OrientationEventListener), I configured them to perform rotation animations. The upper and lower buttons rotate perfectly, but the middle one does not work. Its pivot point seems to be off.
Here is the animation layout:
<?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 this is how I run 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, which is 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 why the middle button (action) doesn't rotate around the correct pivot point?
One thing I noticed is that after the rotation, the middle button is aligned with the vertices of the other two smaller buttons (upper and lower buttons).
!
, celestialorb.