android.view.animation.Transformation类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中android.view.animation.Transformation类的一些代码示例,展示了Transformation类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transformation类的具体详情如下:
包路径:android.view.animation.Transformation
类名称:Transformation

Transformation介绍

暂无

代码示例

代码示例来源:origin: Ramotion/folding-cell-android

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
  final Camera camera = mCamera;
  final Matrix matrix = t.getMatrix();
  final float fromDegrees = mFromDegrees;
  final float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
  camera.save();
  camera.rotateX(degrees);
  camera.getMatrix(matrix);
  camera.restore();
  matrix.preTranslate(-mCenterX, -mCenterY);
  matrix.postTranslate(mCenterX, mCenterY);
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
  protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
      t.setAlpha(mAlpha);
      transformMatrix(t.getMatrix(), view);
    }
  }
}

代码示例来源:origin: stackoverflow.com

Transformation transformation = new Transformation();
float[] matrix = new float[9];
currentAnimation.getTransformation(AnimationUtils.currentAnimationTimeMillis(), transformation);
transformation.getMatrix().getValues(matrix);
float y = matrix[Matrix.MTRANS_Y];

代码示例来源:origin: kakajika/FragmentAnimations

protected void applyTransformation(Transformation t) {
  final Matrix m = t.getMatrix();
  final float w = mWidth;
  final float h = mHeight;
    camera.getMatrix(m);
    camera.restore();
    m.preTranslate(-pX, -pY);
    m.postTranslate(pX, pY);
  final float sY = mScaleY;
  if ((sX != 1.0f) || (sY != 1.0f)) {
    m.postScale(sX, sY);
    final float sPX = -(pX / w) * ((sX * w) - w);
    final float sPY = -(pY / h) * ((sY * h) - h);
  m.postTranslate(mTranslationX, mTranslationY);
  t.setAlpha(mAlpha);

代码示例来源:origin: dalong982242260/CarrouselView

protected boolean getChildStaticTransformation(View child, Transformation transformation) {
  transformation.clear();
  transformation.setTransformationType(Transformation.TYPE_MATRIX);
  final Matrix matrix = transformation.getMatrix();
  matrix.preTranslate(-centerX, -centerY);
  matrix.postTranslate(centerX, centerY);
  matrix.getValues(values);

代码示例来源:origin: stackoverflow.com

@Override
 protected boolean getChildStaticTransformation(View child, Transformation t) {
   Matrix matrix = t.getMatrix();
     int centerX = (child.getWidth() / 2);
     int centerY = (child.getHeight() / 2);
   t.clear();
   t.setTransformationType(Transformation.TYPE_MATRIX);
   mCamera.save();
   if (child == getChildAt(0)) {
     mCamera.translate(pixels to the right,pixels to the bottom,
         to the z axis);
     mCamera.getMatrix(matrix);
     mCamera.restore();
     matrix.preTranslate(-centerX, -centerY);
     matrix.postTranslate(centerX, centerY);
   } 
   return true;
 }

代码示例来源:origin: geminiwen/AndroidCubeDemo

@Override
  protected void applyTransformation(float interpolatedTime, Transformation t) {
    super.applyTransformation(interpolatedTime, t);

    float rotate = (- sFinalDegree * interpolatedTime);
    mCamera.save();
    mCamera.translate((mWidth - interpolatedTime * mWidth), 0, 0);
    mCamera.rotateY(rotate);
    mCamera.getMatrix(mMatrix);
    mCamera.restore();

    mMatrix.postTranslate(0, mHeight / 2);
    mMatrix.preTranslate(- mWidth, - mHeight / 2);

    t.getMatrix().postConcat(mMatrix);
  }
}

代码示例来源:origin: hiteshsahu/ECommerce-App-Android

protected void applyTransformation(float interpolatedTime, Transformation t) {
    Matrix tran = t.getMatrix();
    tran.postTranslate(_offsetx, _offsety);
    tran.postRotate(_angel, _anchorx, _anchory);
  }
};

代码示例来源:origin: stackoverflow.com

public class MyRelativeLayout extends RelativeLayout {    
  public MyRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    init();
  }

  public MyRelativeLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();
  }

  public MyRelativeLayout(Context context) {
    super(context);
    init();
  }

  private void init() {
    setStaticTransformationsEnabled(true);
  }

  @Override
  protected boolean getChildStaticTransformation(View child, Transformation t) {
    t.setTransformationType(Transformation.TYPE_MATRIX);
    Matrix m = t.getMatrix();
    m.reset();
    m.postRotate(180, child.getWidth() / 2.0f, child.getHeight() / 2.0f);
    return true;
  }
}

代码示例来源:origin: stackoverflow.com

/**
 * A custom animation to move and scale the numbers.
 * 
 */
public class NumberAnimation extends Animation
{
  final public static float MINIMUM = 3;
  private int mHorizontal;
  private int mScaling;

  public NumberAnimation(int horizontalMovement, int scaling)
  {
    mHorizontal = horizontalMovement;
    mScaling = scaling;
  }

  @Override
  protected void applyTransformation(float interpolatedTime, Transformation t)
  {
    // Cycloid repeats every 2pi - scale interpolatedTime to that
    double time = 2 * Math.PI * interpolatedTime;
    // Cycloid function
    float currentScale = (float) (mScaling * (1 - Math.cos(time))) + MINIMUM;
    Matrix matrix = t.getMatrix();
    matrix.preScale(currentScale, currentScale);
    matrix.postTranslate(mHorizontal * interpolatedTime, 0);
  }
}

代码示例来源:origin: supertaohaili/book

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
  Matrix matrix=t.getMatrix();//缩放方法
  if (mReverse) {
    matrix.postScale(1 + (scaleTimes - 1) * (1.0f - interpolatedTime), 1 + (scaleTimes - 1) * (1.0f - interpolatedTime), mPivotX - mPivotXValue, mPivotY - mPivotYValue);
  } else {
   //  matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX, mPivotY);
    matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX - mPivotXValue , mPivotY - mPivotYValue );
  }
  float a = mPivotX - mPivotXValue;
  float b = mPivotY - mPivotYValue;
}
//缩放点坐标值

代码示例来源:origin: stackoverflow.com

protected boolean getChildStaticTransformation(View child, Transformation t) {
  t.clear();
  t.setTransformationType(Transformation.TYPE_MATRIX);
  final Matrix matrix = t.getMatrix();
  float childCenterPos = child.getLeft() + (child.getWidth() / 2f);
  float center = getWidth() / 2;
  float diff = Math.abs(center - childCenterPos);
  float scale = diff / getWidth();

  matrix.setScale(1 - (scale), 1 - (scale));

  return true;
}

代码示例来源:origin: stackoverflow.com

Transformation outTransformation = new Transformation();
myAnimation.getTransformation(currentTime, outTransformation);
Matrix transformationMatrix = outTransformation.getMatrix();
float[] matrixValues = new float[9];
transformationMatrix.getValues(matrixValues);
float transX = matrixValues[Matrix.MTRANS_X];
float transY = matrixValues[Matrix.MTRANS_Y];

代码示例来源:origin: stackoverflow.com

Transformation trans = new Transformation();
anim.getTransformation(time, trans);
Matrix m = trans.getMatrix();
m.getValues(values);
if (trans.getAlpha() > 0.5){
  view.setVisibility(VISIBLE);
} else {

代码示例来源:origin: binaryroot/CarouselView

private final Matrix getChildTransformationMatrix(final CarouselItemHolder item,
    final Transformation transformation) {
  float scale = item.getItemScale();
  float scaleXOff = item.getWidth() / 2.0f * (1.0f - scale);
  float centerX = (float) getWidth() / 2;
  scaleXOff += (item.getItemX() + item.getWidth() / 2 - centerX)
      * mViewCoefficientHolder.mDiameterScale;
  final Matrix matrix = transformation.getMatrix();
  matrix.setTranslate(item.getItemX() + scaleXOff, item.getItemY());
  matrix.preScale(scale, scale);
  return matrix;
}

代码示例来源:origin: Rachel-Ding/Android-Tiny-Projects

@Override
  protected void applyTransformation(float interpolatedTime, Transformation t) { //(补间时间,变化对象)

    //-----1------透明度变化效果
//        t.setAlpha(interpolatedTime);

    //----2-------这里是没有动画过渡的,是瞬间移动
//        t.getMatrix().setTranslate(200,200);
    //-----3------这里是一个过程
//        t.getMatrix().setTranslate(200*interpolatedTime,200*interpolatedTime);

    //------4-----左右摇摆效果
    t.getMatrix().setTranslate((float)(Math.sin(interpolatedTime*20)*50),0);

    super.applyTransformation(interpolatedTime, t);
  }
}

代码示例来源:origin: square/assertj-android

public TransformationAssert hasMatrix(Matrix matrix) {
 isNotNull();
 Matrix actualMatrix = actual.getMatrix();
 assertThat(actualMatrix) //
   .overridingErrorMessage("Expected matrix <%s> but was <%s>.", matrix, actualMatrix) //
   .isEqualTo(matrix);
 return this;
}

代码示例来源:origin: stackoverflow.com

private final Transformation mTransformation;

public ListView3d(Context context, AttributeSet attrs) {
  super(context, attrs);
  if (!isInEditMode()) {
    setStaticTransformationsEnabled(true);
    mTransformation = new Transformation();
    mTransformation.setTransformationType(Transformation.TYPE_MATRIX);
  } else {
    mTransformation = null;
  }       
}

@Override
protected boolean getChildStaticTransformation(View child, Transformation t) {
  mTransformation.getMatrix().reset();
  final int childTop = Math.max(0,child.getTop());
  final int parentHeight = getHeight();
  final float scale = (float)(parentHeight-(childTop/2))/getHeight();
  Log.i("scale",scale+"");
  final float px = child.getLeft() + (child.getWidth()) / 2;
  final float py = child.getTop() + (child.getHeight()) / 2;
  mTransformation.getMatrix().postScale(scale, scale, px, py);
  t.compose(mTransformation);
  return true;
}

代码示例来源:origin: stackoverflow.com

final boolean isFirstOrLast = position == 0 || (position == getAdapter().getCount() - 1);
if (overscrollEffect.isOverScrolling() && isFirstOrLast) {
  t.clear();
  t.setTransformationType(Transformation.TYPE_MATRIX);
  t.getMatrix().reset();
  final float translateX = overScrollTranslation * (overscrollEffect.overScroll > 0 ?
      Math.min(overscrollEffect.overScroll, 1) : Math.max(overscrollEffect.overScroll, -1));
  camera.save();
  camera.translate(-translateX, 0, 0);
  camera.getMatrix(t.getMatrix());
  t.getMatrix().preTranslate(-dx, -dy);
  t.getMatrix().postTranslate(dx, dy);
  camera.restore();

代码示例来源:origin: stackoverflow.com

Transformation transformation = new Transformation() {

相关文章