neha
neha

Reputation: 6377

Rotate button about X-axis in an Android app

I want to rotate a button about X-axis when clicked and then display a different image so it creates an effect that after button click it's flipping and showing a different image which is at its backside.

I'm using following xml for rotation of button:

  <set xmlns:android="http://schemas.android.com/apk/res/android"
 android:shareInterpolator="false">
  <set android:interpolator="@android:anim/decelerate_interpolator">

  <rotate 
         android:fromDegrees="0" 
         android:toDegrees="-360"
         android:pivotX="25%"
         android:pivotY="25%"
         android:fromXDelta="0"
         android:toXDelta="0"
         android:fromYDelta="0"
         android:toYDelta="0"             
         android:duration="400" />
</set>
</set>

But it's rotating the button in 2-D plane about the button's center.

Upvotes: 0

Views: 6502

Answers (3)

Gordon Freeman
Gordon Freeman

Reputation: 1167

It's been a while since this question is posted, but just for the record - there is a way in newer versions of android, and for back compatibility use http://nineoldandroids.com/

Upvotes: 1

taf
taf

Reputation: 429

I have a flip example here:

http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html

Upvotes: 2

Reuben Scratton
Reuben Scratton

Reputation: 38707

I'm afraid the conventional graphics and animation APIs are 2D. To use that 3rd dimension you'd need to look into OpenGL, which is non-trivial.

You might be able to fake a depth effect by writing a custom animation that uses setPolyToPoly to warp your initial rect into a trapezoid.

Upvotes: 1

Related Questions