本文整理了Java中android.widget.ImageView.getTranslationY()
方法的一些代码示例,展示了ImageView.getTranslationY()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.getTranslationY()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:getTranslationY
暂无
代码示例来源:origin: jdsjlzx/LRecyclerView
@Override public void onAnimationUpdate(ValueAnimator animation) {
if (mRefreshView.getTranslationY() == mRefreshHideTranslationY) {
animation.cancel();
} else {
mRefreshView.setTranslationY((Float) animation.getAnimatedValue());
}
}
});
代码示例来源:origin: jdsjlzx/LRecyclerView
@Override public void onAnimationUpdate(ValueAnimator animation) {
if (mRefreshView.getTranslationY() == mRefreshHideTranslationY) {
animation.cancel();
} else {
mRefreshView.setTranslationY((Float) animation.getAnimatedValue());
}
}
});
代码示例来源:origin: jdsjlzx/LRecyclerView
private void refreshRest() {
ValueAnimator animator = ValueAnimator.ofFloat(mRefreshView.getTranslationY(), mRefreshHideTranslationY);
animator.setStartDelay(60);
animator.setDuration(300).start();
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
if (mRefreshView.getTranslationY() == mRefreshHideTranslationY) {
animation.cancel();
} else {
mRefreshView.setTranslationY((Float) animation.getAnimatedValue());
}
}
});
}
}
代码示例来源:origin: jdsjlzx/LRecyclerView
private void refreshRest() {
ValueAnimator animator = ValueAnimator.ofFloat(mRefreshView.getTranslationY(), mRefreshHideTranslationY);
animator.setStartDelay(60);
animator.setDuration(300).start();
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
if (mRefreshView.getTranslationY() == mRefreshHideTranslationY) {
animation.cancel();
} else {
mRefreshView.setTranslationY((Float) animation.getAnimatedValue());
}
}
});
}
}
代码示例来源:origin: jdsjlzx/LRecyclerView
/**
* refreshView在刷新区间内相对位移并跟随位移速度旋转
*/
private void refreshTranslation(int currentHeight, float offSet) {
if ((currentHeight - mHeaderViewHeight) / 2 < mRefreshShowTranslationY - mRefreshHideTranslationY) { // 判断是否在非刷新区间
float translationY = mRefreshView.getTranslationY() - offSet / 2; // 布局高度增加offset 相当于距离上边距offSet / 2
if (translationY > mRefreshShowTranslationY) {
translationY = mRefreshShowTranslationY;
} else if (translationY < mRefreshHideTranslationY) {
translationY = mRefreshHideTranslationY;
}
if (Math.abs(translationY) != mRefreshView.getTranslationY()) {
mRefreshView.setTranslationY(translationY);
}
}
mRefreshView.setRotation(mRotateAngle -= offSet);//旋转,角度大小跟随偏移量
}
代码示例来源:origin: jdsjlzx/LRecyclerView
/**
* refreshView在刷新区间内相对位移并跟随位移速度旋转
*/
private void refreshTranslation(int currentHeight, float offSet) {
if ((currentHeight - mHeaderViewHeight) / 2 < mRefreshShowTranslationY - mRefreshHideTranslationY) { // 判断是否在非刷新区间
float translationY = mRefreshView.getTranslationY() - offSet / 2; // 布局高度增加offset 相当于距离上边距offSet / 2
if (translationY > mRefreshShowTranslationY) {
translationY = mRefreshShowTranslationY;
} else if (translationY < mRefreshHideTranslationY) {
translationY = mRefreshHideTranslationY;
}
if (Math.abs(translationY) != mRefreshView.getTranslationY()) {
mRefreshView.setTranslationY(translationY);
}
}
mRefreshView.setRotation(mRotateAngle -= offSet);//旋转,角度大小跟随偏移量
}
代码示例来源:origin: jdsjlzx/LRecyclerView
@Override public boolean onRelease() {
boolean isOnRefresh = false;
int currentHeight = mHeaderView.getLayoutParams().height;// 使用 mHeaderView.getLayoutParams().height 可以防止快速快速下拉的时候图片不回弹
if (currentHeight > mHeaderViewHeight) {
if ((currentHeight - mHeaderViewHeight) / 2 > mRefreshShowTranslationY - mRefreshHideTranslationY && mState < STATE_REFRESHING) {
setState(STATE_REFRESHING);
isOnRefresh = true;
}
headerRest();
}
if (!isOnRefresh && mRefreshView.getTranslationY() != mRefreshHideTranslationY) {
refreshRest();
}
return isOnRefresh;
}
代码示例来源:origin: jdsjlzx/LRecyclerView
@Override public boolean onRelease() {
boolean isOnRefresh = false;
int currentHeight = getLayoutParams().height;// 使用 mHeaderView.getLayoutParams().height 可以防止快速快速下拉的时候图片不回弹
if (currentHeight > mHeaderViewHeight) {
if ((currentHeight - mHeaderViewHeight) / 2 > mRefreshShowTranslationY - mRefreshHideTranslationY && mState < STATE_REFRESHING) {
setState(STATE_REFRESHING);
isOnRefresh = true;
}
headerRest();
}
if (!isOnRefresh && mRefreshView.getTranslationY() != mRefreshHideTranslationY) {
refreshRest();
}
return isOnRefresh;
}
代码示例来源:origin: iielse/ImageWatcher
vsDefault.height * vsCurrent.scaleY / 2 - vsDefault.height / 2 <= iSource.getTranslationY()) {
代码示例来源:origin: iielse/ImageWatcher
/**
* 处理结束下拉退出的手指事件,进行退出图片查看或者恢复到初始状态的收尾动画<br>
* 还需要还原背景色
*/
private void handleExitTouchResult() {
if (iSource == null) return;
if (mExitRef > 0.75f) {
ViewState vsExit = ViewState.read(iSource, ViewState.STATE_EXIT);
if (vsExit != null) animSourceViewStateTransform(iSource, vsExit);
animBackgroundTransform(0xFF000000, 0);
} else {
ViewState vsOrigin = ViewState.read(iSource, ViewState.STATE_ORIGIN);
if (vsOrigin != null) {
if (vsOrigin.alpha == 0) {
vsOrigin.translationX(iSource.getTranslationX()).translationY(iSource.getTranslationY());
}
animSourceViewStateTransform(iSource, vsOrigin);
}
animBackgroundTransform(0x00000000, STATE_EXIT_HIDING);
((FrameLayout) iSource.getParent()).getChildAt(2).animate().alpha(0).start();
}
}
代码示例来源:origin: richakhanna/physicsbasedanimation
@Override
public boolean onTouch(View v, MotionEvent motionEvent) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_MOVE) {
float deltaX = motionEvent.getRawX() - lastX;
float deltaY = motionEvent.getRawY() - lastY;
mViewLead.setTranslationX(deltaX + mViewLead.getTranslationX());
mViewLead.setTranslationY(deltaY + mViewLead.getTranslationY());
animFirstFollowerX.animateToFinalPosition(mViewLead.getTranslationX());
animFirstFollowerY.animateToFinalPosition(mViewLead.getTranslationY());
}
lastX = motionEvent.getRawX();
lastY = motionEvent.getRawY();
return true;
}
});
代码示例来源:origin: stackoverflow.com
public Bitmap mergeBitmaps() {
Bitmap baseBitmap = ((BitmapDrawable) image.getDrawable()).getBitmap();
Bitmap mergedBitmap = Bitmap.createBitmap(baseBitmap.getWidth(), baseBitmap.getHeight(), baseBitmap.getConfig());
Canvas canvas = new Canvas(mergedBitmap);
canvas.drawBitmap(baseBitmap, new Matrix(), null);
for (ImageView sticker: stickers) {
float viewSizeRatio = (float) sticker.getWidth() / image.getWidth();
float bitmapSizeRatio = (float) sticker.getDrawable().getBounds().width() / image.getDrawable().getBounds().width();
float ratioFactor = viewSizeRatio / bitmapSizeRatio;
float deltaX = sticker.getTranslationX()* ratioFactor;
float deltaY = sticker.getTranslationY()* ratioFactor;
float scaleX = sticker.getScaleX()* ratioFactor;
float scaleY = sticker.getScaleY()* ratioFactor;
float rotation = sticker.getRotation();
Matrix matrix = new Matrix();
matrix.postScale(scaleX, scaleY);
matrix.postRotate(rotation);
matrix.postTranslate(deltaX, deltaY);
Bitmap stickerBitmap = ((BitmapDrawable) sticker.getDrawable()).getBitmap();
canvas.drawBitmap(stickerBitmap, matrix, null);
}
return mergedBitmap;
}
代码示例来源:origin: stackoverflow.com
final int X = (int) event.getRawX();
final int Y = (int) event.getRawY();
ImageView j = (ImageView) findViewById(R.id.image);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
_xDelta = (int) (X - j.getTranslationX());
_yDelta = (int) (Y - j.getTranslationY());
break;
case MotionEvent.ACTION_UP:
_xDelta = 100;
_yDelta = 100;
break;
case MotionEvent.ACTION_MOVE:
j.setTranslationX(X - _xDelta);
j.setTranslationY(Y - _yDelta);
if (X >= 370 && X <= 500 && Y >= 250 && Y <= 420) {
Log.i(null, "Region 1 initiated");
// Do whatever...
}
代码示例来源:origin: byc4426/ImageWatcher
vsDefault.height * vsCurrent.scaleY / 2 - vsDefault.height / 2 <= iSource.getTranslationY()) {
代码示例来源:origin: vpaliy/android-material-motion
prev.setScaleX(0);
prev.setScaleY(0);
Path arcPath = createArcPath(playPause, 0, 0, -playPause.getTranslationY());
ValueAnimator pathAnimator = ValueAnimator.ofFloat(0, 1);
pathAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
代码示例来源:origin: byc4426/ImageWatcher
/**
* 处理结束下拉退出的手指事件,进行退出图片查看或者恢复到初始状态的收尾动画<br>
* 还需要还原背景色
*/
private void handleExitTouchResult() {
if (iSource == null) return;
if (mExitRef > 0.75f) {
ViewState vsExit = ViewState.read(iSource, ViewState.STATE_EXIT);
if (vsExit != null) animSourceViewStateTransform(iSource, vsExit);
animBackgroundTransform(0xFF000000, 0);
} else {
ViewState vsOrigin = ViewState.read(iSource, ViewState.STATE_ORIGIN);
if (vsOrigin != null) {
if (vsOrigin.alpha == 0) {
vsOrigin.translationX(iSource.getTranslationX()).translationY(iSource.getTranslationY());
}
animSourceViewStateTransform(iSource, vsOrigin);
}
animBackgroundTransform(0x00000000, STATE_EXIT_HIDING);
((FrameLayout) iSource.getParent()).getChildAt(2).animate().alpha(0).start();
}
}
代码示例来源:origin: IFTTT/SparkleMotion
new TranslationAnimation(page, 0, smallCloud.getTranslationY(), 0, 0, true);
TranslationAnimation translationAnimation2 =
new TranslationAnimation(page, 0, bigCloud.getTranslationY(), 0, 0, true);
内容来源于网络,如有侵权,请联系作者删除!