android view动态翻转切换

茉个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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值