private Animation generateLineLTRAnimation(final RectF rectF, long offset) {
final float currentLeft = rectF.left;
final float currentRight = rectF.right;
Animation animation = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
if (getCurrentState() == HBButtonState.NORMAL) {
rectF.set(rectF.left, rectF.top, currentRight - (currentRight - currentLeft) / 2 * interpolatedTime, rectF.bottom);
} else {
rectF.set(rectF.left, rectF.top, currentRight + (currentRight - currentLeft) * interpolatedTime, rectF.bottom);
}
invalidate();
}
};
animation.setDuration(getAnimationDuration());
animation.setStartOffset(offset);
return animation;
}
java类android.view.animation.Transformation的实例源码
HBButton.java 文件源码
项目:Hamburger-Button
阅读 30
收藏 0
点赞 0
评论 0
HBButton.java 文件源码
项目:Hamburger-Button
阅读 30
收藏 0
点赞 0
评论 0
private Animation generateLineRTLAnimation(final RectF rectF, long offset) {
final float currentLeft = rectF.left;
final float currentRight = rectF.right;
Animation animation = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
if (getCurrentState() == HBButtonState.NORMAL) {
rectF.set(currentLeft + (currentRight - currentLeft) / 2 * interpolatedTime, rectF.top, rectF.right, rectF.bottom);
} else {
rectF.set(currentLeft - (currentRight - currentLeft) * interpolatedTime, rectF.top, rectF.right, rectF.bottom);
}
invalidate();
}
};
animation.setDuration(getAnimationDuration());
animation.setStartOffset(offset);
return animation;
}
SwipeRefreshLayout.java 文件源码
项目:GeekZone
阅读 38
收藏 0
点赞 0
评论 0
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
int targetTop = 0;
int endTarget = 0;
if (!mUsingCustomStart) {
switch (mDirection) {
case BOTTOM:
endTarget = getMeasuredHeight() - (int) (mSpinnerFinalOffset);
break;
case TOP:
default:
endTarget = (int) (mSpinnerFinalOffset - Math.abs(mOriginalOffsetTop));
break;
}
} else {
endTarget = (int) mSpinnerFinalOffset;
}
targetTop = (mFrom + (int) ((endTarget - mFrom) * interpolatedTime));
int offset = targetTop - mCircleView.getTop();
setTargetOffsetTopAndBottom(offset, false /* requires update */);
}
CourseInfoGallery.java 文件源码
项目:HutHelper
阅读 25
收藏 0
点赞 0
评论 0
private void transformImageBitmap(View child, Transformation t,
int rotationAngle) {
mCamera.save();
final Matrix imageMatrix = t.getMatrix();
final int imageHeight = child.getLayoutParams().height;
final int imageWidth = child.getLayoutParams().width;
final int rotation = Math.abs(rotationAngle);
mCamera.translate(0.0f, 0.0f, 100.0f);
// As the angle of the view gets less, zoom in
if (rotation < mMaxRotationAngle) {
float zoomAmount = (float) (mMaxZoom + (rotation * 1.5));
mCamera.translate(0.0f, 0.0f, zoomAmount);
}
mCamera.rotateY(rotationAngle);
mCamera.getMatrix(imageMatrix);
imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));
mCamera.restore();
}
Rotate3dAnimation.java 文件源码
项目:shareNote
阅读 24
收藏 0
点赞 0
评论 0
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final Matrix matrix = t.getMatrix();
mCamera.save();
switch (mRollType) {
case ROLL_BY_X:
mCamera.rotateX(degrees);
break;
case ROLL_BY_Y:
mCamera.rotateY(degrees);
break;
case ROLL_BY_Z:
mCamera.rotateZ(degrees);
break;
}
mCamera.getMatrix(matrix);
mCamera.restore();
matrix.preTranslate(-mPivotX, -mPivotY);
matrix.postTranslate(mPivotX, mPivotY);
}
ISwipeRefreshLayout.java 文件源码
项目:AndroidUiKit
阅读 23
收藏 0
点赞 0
评论 0
@SuppressLint("NewApi")
private void startScaleDownReturnToStartAnimation(Animation.AnimationListener listener) {
mStartingScale = mRefreshView.getScaleX();
mScaleDownToStartAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
setAnimationProgress(targetScale);
moveToStart(interpolatedTime);
}
};
mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
if (listener != null) {
mScaleDownToStartAnimation.setAnimationListener(listener);
}
mRefreshView.clearAnimation();
mRefreshView.startAnimation(mScaleDownToStartAnimation);
}
SwipeRefreshLayout.java 文件源码
项目:android-source-codes
阅读 25
收藏 0
点赞 0
评论 0
private void startScaleDownReturnToStartAnimation(int from,
Animation.AnimationListener listener) {
mFrom = from;
if (isAlphaUsedForScale()) {
mStartingScale = mProgress.getAlpha();
} else {
mStartingScale = ViewCompat.getScaleX(mCircleView);
}
mScaleDownToStartAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
setAnimationProgress(targetScale);
moveToStart(interpolatedTime);
}
};
mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
if (listener != null) {
mCircleView.setAnimationListener(listener);
}
mCircleView.clearAnimation();
mCircleView.startAnimation(mScaleDownToStartAnimation);
}
SwipeRefreshLayout.java 文件源码
项目:BookReader-master
阅读 36
收藏 0
点赞 0
评论 0
private Animation startAlphaAnimation(final int startingAlpha, final int endingAlpha) {
// Pre API 11, alpha is used in place of scale. Don't also use it to
// show the trigger point.
if (mScale && isAlphaUsedForScale()) {
return null;
}
Animation alpha = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
mProgress
.setAlpha((int) (startingAlpha+ ((endingAlpha - startingAlpha)
* interpolatedTime)));
}
};
alpha.setDuration(ALPHA_ANIMATION_DURATION);
// Clear out the previous animation listeners.
mCircleView.setAnimationListener(null);
mCircleView.clearAnimation();
mCircleView.startAnimation(alpha);
return alpha;
}
SwipeToRefreshLayout.java 文件源码
项目:SwipeToRefresh
阅读 30
收藏 0
点赞 0
评论 0
private Animation startAlphaAnimation(final int startingAlpha, final int endingAlpha) {
// Pre API 11, alpha is used in place of scale. Don't also use it to
// show the trigger point.
if (mScale && isAlphaUsedForScale()) {
return null;
}
Animation alpha = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
mProgress
.setAlpha((int) (startingAlpha + ((endingAlpha - startingAlpha)
* interpolatedTime)));
}
};
alpha.setDuration(ALPHA_ANIMATION_DURATION);
// Clear out the previous animation listeners.
mCircleView.setAnimationListener(null);
mCircleView.clearAnimation();
mCircleView.startAnimation(alpha);
return alpha;
}
RotateAndTranslateAnimation.java 文件源码
项目:FLFloatingButton
阅读 25
收藏 0
点赞 0
评论 0
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float degrees = mFromDegrees + ((mToDegrees - mFromDegrees) * interpolatedTime);
if (mPivotX == 0.0f && mPivotY == 0.0f) {
t.getMatrix().setRotate(degrees);
} else {
t.getMatrix().setRotate(degrees, mPivotX, mPivotY);
}
float dx = mFromXDelta;
float dy = mFromYDelta;
if (mFromXDelta != mToXDelta) {
dx = mFromXDelta + ((mToXDelta - mFromXDelta) * interpolatedTime);
}
if (mFromYDelta != mToYDelta) {
dy = mFromYDelta + ((mToYDelta - mFromYDelta) * interpolatedTime);
}
t.getMatrix().postTranslate(dx, dy);
}
FlipAnimation.java 文件源码
项目:Flashcards-Demo
阅读 25
收藏 0
点赞 0
评论 0
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final double radians = Math.PI * interpolatedTime;
float degrees = (float) (180.0 * radians / Math.PI);
if (interpolatedTime >= 0.5f) { // Alternate the visibility of views at the exact half of animation duration.
degrees -= 180.f;
fromView.setVisibility(View.GONE);
toView.setVisibility(View.VISIBLE);
}
if (forward)
degrees = -degrees;
final Matrix matrix = t.getMatrix();
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
SuperSwipeRefreshLayout.java 文件源码
项目:MultiSelecter
阅读 27
收藏 0
点赞 0
评论 0
private void startScaleUpAnimation(AnimationListener listener) {
mHeadViewContainer.setVisibility(View.VISIBLE);
mScaleAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime,
Transformation t) {
setAnimationProgress(interpolatedTime);
}
};
mScaleAnimation.setDuration(mMediumAnimationDuration);
if (listener != null) {
mHeadViewContainer.setAnimationListener(listener);
}
mHeadViewContainer.clearAnimation();
mHeadViewContainer.startAnimation(mScaleAnimation);
}
ExpandTextView.java 文件源码
项目:Aurora
阅读 37
收藏 0
点赞 0
评论 0
public void expand() {
if (!isExpand) {
isExpand = true;
mText.setTextColor(Color.TRANSPARENT);
mExpandText.setTextColor(mTextColor);
Animation animation = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
ViewGroup.LayoutParams params = ExpandTextView.this.getLayoutParams();
params.height = mStart + (int) ((mEnd - mStart) * interpolatedTime);
setLayoutParams(params);
}
};
animation.setDuration(500);
startAnimation(animation);
}
}
Rotate3d.java 文件源码
项目:FragmentRigger
阅读 36
收藏 0
点赞 0
评论 0
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
Camera camera = new Camera();
camera.save();
// 设置camera动作为绕Y轴旋转
// 总共旋转180度,因此计算在每个补间时间点interpolatedTime的角度即为两着相乘
// camera.rotateX(deg * interpolatedTime);
camera.rotateY(180 * interpolatedTime);
// camera.rotateZ(180 * interpolatedTime);
//
// 根据camera动作产生一个matrix,赋给Transformation的matrix,以用来设置动画效果
Matrix matrix = t.getMatrix();
camera.getMatrix(matrix);
camera.restore();
//经过以下平移,才能以view的中心点进行翻转
matrix.preTranslate(-view.getWidth() / 2, -view.getHeight() / 2);
matrix.postTranslate(view.getWidth() / 2, view.getHeight() / 2);
}
CropImageAnimation.java 文件源码
项目:Android-Demo_ImageCroper
阅读 20
收藏 0
点赞 0
评论 0
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
mAnimRect.left = mStartCropWindowRect.left + (mEndCropWindowRect.left - mStartCropWindowRect.left) * interpolatedTime;
mAnimRect.top = mStartCropWindowRect.top + (mEndCropWindowRect.top - mStartCropWindowRect.top) * interpolatedTime;
mAnimRect.right = mStartCropWindowRect.right + (mEndCropWindowRect.right - mStartCropWindowRect.right) * interpolatedTime;
mAnimRect.bottom = mStartCropWindowRect.bottom + (mEndCropWindowRect.bottom - mStartCropWindowRect.bottom) * interpolatedTime;
mCropOverlayView.setCropWindowRect(mAnimRect);
for (int i = 0; i < mAnimPoints.length; i++) {
mAnimPoints[i] = mStartBoundPoints[i] + (mEndBoundPoints[i] - mStartBoundPoints[i]) * interpolatedTime;
}
mCropOverlayView.setBounds(mAnimPoints, mImageView.getWidth(), mImageView.getHeight());
for (int i = 0; i < mAnimMatrix.length; i++) {
mAnimMatrix[i] = mStartImageMatrix[i] + (mEndImageMatrix[i] - mStartImageMatrix[i]) * interpolatedTime;
}
Matrix m = mImageView.getImageMatrix();
m.setValues(mAnimMatrix);
mImageView.setImageMatrix(m);
mImageView.invalidate();
mCropOverlayView.invalidate();
}
SuperSwipeRefreshLayout.java 文件源码
项目:Amazing
阅读 29
收藏 0
点赞 0
评论 0
private void startScaleDownReturnToStartAnimation(int from,
AnimationListener listener) {
mFrom = from;
mStartingScale = ViewCompat.getScaleX(mHeadViewContainer);
mScaleDownToStartAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime,
Transformation t) {
float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
setAnimationProgress(targetScale);
moveToStart(interpolatedTime);
}
};
mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
if (listener != null) {
mHeadViewContainer.setAnimationListener(listener);
}
mHeadViewContainer.clearAnimation();
mHeadViewContainer.startAnimation(mScaleDownToStartAnimation);
}
SwipeRefreshLayout.java 文件源码
项目:letv
阅读 37
收藏 0
点赞 0
评论 0
private void startScaleUpAnimation(AnimationListener listener) {
this.mCircleView.setVisibility(0);
if (VERSION.SDK_INT >= 11) {
this.mProgress.setAlpha(255);
}
this.mScaleAnimation = new Animation() {
public void applyTransformation(float interpolatedTime, Transformation t) {
SwipeRefreshLayout.this.setAnimationProgress(interpolatedTime);
}
};
this.mScaleAnimation.setDuration((long) this.mMediumAnimationDuration);
if (listener != null) {
this.mCircleView.setAnimationListener(listener);
}
this.mCircleView.clearAnimation();
this.mCircleView.startAnimation(this.mScaleAnimation);
}
GestureRefreshLayout.java 文件源码
项目:gesture-refresh-layout
阅读 38
收藏 0
点赞 0
评论 0
private void startScaleUpAnimation(Animation.AnimationListener listener) {
mRefreshView.setVisibility(View.VISIBLE);
if (android.os.Build.VERSION.SDK_INT >= 11) {
// Pre API 11, alpha is used in place of scale up to show the
// progress circle appearing.
// Don't adjust the alpha during appearance otherwise.
//mProgress.setAlpha(MAX_ALPHA);
}
mScaleAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
setAnimationProgress(interpolatedTime);
}
};
mScaleAnimation.setDuration(mMediumAnimationDuration);
mScaleAnimation.setAnimationListener(listener);
mRefreshView.clearAnimation();
mRefreshView.startAnimation(mScaleAnimation);
}
AnimationUtils.java 文件源码
项目:BuddyBook
阅读 33
收藏 0
点赞 0
评论 0
public static void expand(final View v) {
v.measure(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight();
// Older versions of android (pre API 21) cancel animations for views with a height of 0.
v.getLayoutParams().height = 1;
v.setVisibility(View.VISIBLE);
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
v.getLayoutParams().height = interpolatedTime == 1
? ActionBar.LayoutParams.WRAP_CONTENT
: (int) (targetHeight * interpolatedTime);
v.requestLayout();
}
@Override
public boolean willChangeBounds() {
return true;
}
};
// 1dp/ms
a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
v.startAnimation(a);
}
Rotate3dAnimation.java 文件源码
项目:FreeStreams-TVLauncher
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
AndroidTreeView.java 文件源码
项目:javaide
阅读 24
收藏 0
点赞 0
评论 0
private static void expand(final View v) {
v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight();
v.getLayoutParams().height = 0;
v.setVisibility(View.VISIBLE);
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
v.getLayoutParams().height = interpolatedTime == 1
? LinearLayout.LayoutParams.WRAP_CONTENT
: (int) (targetHeight * interpolatedTime);
v.requestLayout();
}
@Override
public boolean willChangeBounds() {
return true;
}
};
// 1dp/ms
a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
v.startAnimation(a);
}
SRProgressDialog.java 文件源码
项目:SRPrgressDialog
阅读 32
收藏 0
点赞 0
评论 0
@SuppressLint("NewApi")
private void startScaleUpAnimation(Animation.AnimationListener listener) {
mCircleView.setVisibility(View.VISIBLE);
if (android.os.Build.VERSION.SDK_INT >= 11) {
// Pre API 11, alpha is used in place of scale up to show the
// progress circle appearing.
// Don't adjust the alpha during appearance otherwise.
mProgress.setAlpha(MAX_ALPHA);
}
mScaleAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
setAnimationProgress(interpolatedTime);
}
};
mScaleAnimation.setDuration(mMediumAnimationDuration);
if (listener != null) {
mCircleView.setAnimationListener(listener);
}
mCircleView.clearAnimation();
mCircleView.startAnimation(mScaleAnimation);
}
RotateAnimation.java 文件源码
项目:HiBangClient
阅读 32
收藏 0
点赞 0
评论 0
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float deg = 0.0F + 360.0F * interpolatedTime;
Matrix matrix = t.getMatrix();
mCamera.save();
if (mMode == Mode.X)
mCamera.rotateX(deg);
if (mMode == Mode.Y)
mCamera.rotateY(deg);
if (mMode == Mode.Z)
mCamera.rotateZ(deg);
mCamera.getMatrix(matrix);
mCamera.restore();
matrix.preTranslate(-mCenterX, -mCenterY);
matrix.postTranslate(mCenterX, mCenterY);
}
LingjuSwipeRefreshLayout.java 文件源码
项目:AssistantBySDK
阅读 34
收藏 0
点赞 0
评论 0
private void startScaleUpAnimation(final CircleImageView view, Animation.AnimationListener listener) {
view.setVisibility(View.VISIBLE);
if (android.os.Build.VERSION.SDK_INT >= 11) {
// Pre API 11, alpha is used in place of scale up to show the
// progress circle appearing.
// Don't adjust the alpha during appearance otherwise.
if (view == tCircleView)
tProgress.setAlpha(MAX_ALPHA);
else
bProgress.setAlpha(MAX_ALPHA);
}
mScaleAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
setAnimationProgress(view, interpolatedTime);
}
};
mScaleAnimation.setDuration(mMediumAnimationDuration);
if (listener != null) {
view.setAnimationListener(listener);
}
view.clearAnimation();
view.startAnimation(mScaleAnimation);
}
LingjuSwipeUpLoadRefreshLayout.java 文件源码
项目:AssistantBySDK
阅读 41
收藏 0
点赞 0
评论 0
private void startScaleUpAnimation(final CircleImageView view, Animation.AnimationListener listener) {
view.setVisibility(View.VISIBLE);
if (android.os.Build.VERSION.SDK_INT >= 11) {
bProgress.setAlpha(MAX_ALPHA);
}
mScaleAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
setAnimationProgress(view, interpolatedTime);
}
};
mScaleAnimation.setDuration(mMediumAnimationDuration);
if (listener != null) {
view.setAnimationListener(listener);
}
view.clearAnimation();
view.startAnimation(mScaleAnimation);
}
LingjuSwipeUpLoadRefreshLayout.java 文件源码
项目:AssistantBySDK
阅读 39
收藏 0
点赞 0
评论 0
private void startScaleDownReturnToStartAnimation(final CircleImageView view, int from,
Animation.AnimationListener listener) {
mFrom = from;
if (isAlphaUsedForScale()) {
mStartingScale = bProgress.getAlpha();
} else {
mStartingScale = ViewCompat.getScaleX(view);
}
mScaleDownToStartAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
setAnimationProgress(view, targetScale);
moveToStart(interpolatedTime);
}
};
mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
if (listener != null) {
view.setAnimationListener(listener);
}
view.clearAnimation();
view.startAnimation(mScaleDownToStartAnimation);
}
Rotate3dAnimation.java 文件源码
项目:BookLoadingView
阅读 19
收藏 0
点赞 0
评论 0
@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);
}
ActMFBForm.java 文件源码
项目:MyFlightbookAndroid
阅读 32
收藏 0
点赞 0
评论 0
private void collapseView(final View v) {
final int initialHeight = v.getMeasuredHeight();
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if (interpolatedTime == 1) {
v.setVisibility(View.GONE);
} else {
v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
v.requestLayout();
}
}
@Override
public boolean willChangeBounds() {
return true;
}
};
a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
v.startAnimation(a);
}
UdeskExpandableLayout.java 文件源码
项目:react-native-udesk
阅读 19
收藏 0
点赞 0
评论 0
@Override
protected void applyTransformation(float interpolatedTime,
Transformation t) {
try {
int newHeight;
if (down) {
newHeight = (int) (targetHeight * interpolatedTime);
} else {
newHeight = (int) (targetHeight * (1 - interpolatedTime));
}
view.getLayoutParams().height = newHeight;
view.requestLayout();
if (view.getVisibility() == View.GONE) {
view.setVisibility(View.VISIBLE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
GalleryView.java 文件源码
项目:Hillffair17
阅读 29
收藏 0
点赞 0
评论 0
public void collapse(final View v) {
final int initialHeight = v.getMeasuredHeight();
Animation a = new Animation()
{
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if(interpolatedTime == 1){
v.setVisibility(View.GONE);
}else{
v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
v.requestLayout();
}
}
@Override
public boolean willChangeBounds() {
return true;
}
};
// 1dp/ms
a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
v.startAnimation(a);
}