• Android 图片转动效果(一)


    我们先来看看效果图:

    <ignore_js_op>190302td1aajjrtgddurnt.jpg

    <ignore_js_op>1903047yc2vg49ycpqpc4x.jpg


    看见效果就是旋转前和旋转后的效果

           如果是你想要的效果,那么继续往下看,如果不是,那可以跳过了。这是一个动画,而不是用matrix实现的直接翻转图片。
           我这个是根据APIDemo,简单修改写的需要一个Rotate3d,类,继承,Animation这个类可以直接拷过去,不用做任何的修改。其中的方法自己找相关资料研究。

    java代码:

    public class Rotate3d 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; 

     

    public Rotate3d(float fromDegrees, float toDegrees, float centerX, float centerY, float depthZ, boolean reverse) { 

     

    mFromDegrees = fromDegrees; 

     

    mToDegrees = toDegrees; 

     

    mCenterX = centerX; 

     

    mCenterY = centerY; 

     

    mDepthZ = depthZ; 

     

    mReverse = reverse; 

     

     

    @Override 

     

    public void initialize(int width, int height, int parentWidth, int parentHeight) { 

     

    super.initialize(width, height, parentWidth, parentHeight); 

     

    mCamera = new Camera(); 

     

     

    @Override 

     

    protected void applyTransformation(float interpolatedTime, Transformation t) { 

     

    final float fromDegrees = mFromDegrees; 

     

    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); 

     

    final float centerX = mCenterX; 

     

    final float centerY = mCenterY; 

     

    final Camera camera = mCamera; 

     

    final Matrix matrix = t.getMatrix(); 

     

    camera.save(); 

     

    if (mReverse) { 

     

    camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); 

     

    } else { 

     

    camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); 

     

     

    camera.rotateY(degrees); 

     

    camera.getMatrix(matrix); 

     

    camera.restore(); 

     

    matrix.preTranslate(-centerX, -centerY); 

     

    matrix.postTranslate(centerX, centerY); 

     

     

    复制代码

     

     
  • 相关阅读:
    [WPF系列] window自定义
    [WPF系列]-Prism+EF
    C#基础-事件 继承类无法直接引发基类的事件
    [WPF系列] 高级 调试
    [WPF系列]-DynamicResource与StaticResource的区别
    [WPF系列]-DataBinding 绑定计算表达式
    [WPF系列]- Style
    [WPF系列]-基础 TextBlock
    [WPF系列]-ListBox
    [WPF系列]-DataBinding 枚举类型数据源
  • 原文地址:https://www.cnblogs.com/greywolf/p/2826364.html
Copyright © 2020-2023  润新知