茉个layout文件如下
...
<FrameLayout android:layout_width="wrap_content" android:id="@+id/play_switch_layout"
android:layout_height="wrap_content" android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/audio_player_play_switch_layout_marginright" android:layout_marginTop="@dimen/audio_player_play_switch_layout_margintop">
<Button android:id="@+id/playing_switch_control_page_btn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:visibility="gone"
android:background="@drawable/playing_switch_control_page_bg" />
<Button android:id="@+id/playing_switch_mark_page_btn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="@drawable/playing_switch_mark_page_bg" />
</FrameLayout>
...
使用这个文件作为布局内容的类文件假设为A.java,现在要实现单击Button,两个Button翻转切换的效果。
首先定义类Rotate3dAnimation
public class Rotate3dAnimation extends Animation {
private final float mFromDegrees;
private final float mToDegrees;
private final float mCenterX;
private final float mCenterY;
private final float mDepthZ;
private final boolean mReverse;
private Camera mCamera;
/**
* Creates a new 3D rotation on the Y axis. The rotation is defined by its
* start angle and its end angle. Both angles are in degrees. The rotation
* is performed around a center point on the 2D space, definied by a pair
* of X and Y coordinates, called centerX and centerY. When the animation
* starts, a translation on the Z axis (depth) is performed. The length
* of the translation