本文整理了Java中android.widget.ImageView.getTranslationX()
方法的一些代码示例,展示了ImageView.getTranslationX()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.getTranslationX()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:getTranslationX
暂无
代码示例来源: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: linchupeng/YourWeather
private void playCloud_1Anim() {
float cloud1TranslationX = splashCould1.getTranslationX();
ObjectAnimator anim = ObjectAnimator.ofFloat(splashCould1, "translationX", cloud1TranslationX-250f,cloud1TranslationX);
anim.setDuration(8 * 1000);
anim.start();
}
代码示例来源:origin: linchupeng/YourWeather
private void playCloud_2Anim() {
float cloud2TranslationX = splashCould2.getTranslationX();
ObjectAnimator anim = ObjectAnimator.ofFloat(splashCould2, "translationX", cloud2TranslationX-200f, cloud2TranslationX);
anim.setDuration(7* 1000);
anim.start();
}
代码示例来源:origin: linchupeng/YourWeather
private void playCloud_3Anim() {
float cloud3TranslationX = splashCould3.getTranslationX();
ObjectAnimator anim = ObjectAnimator.ofFloat(splashCould3, "translationX",cloud3TranslationX,-300f,cloud3TranslationX);
anim.setDuration(8 * 1000);
anim.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: prolificinteractive/Chandelier
private void setSelectedIndex(final int newSelectedIndex) {
// Un-select previous index
imageViews.get(selectedIndex).setSelected(false);
selectedIndex = newSelectedIndex;
isAnimating = true;
final int iW = measuredWidth / ornaments.size();
final int target = iW * selectedIndex + (iW - selectedSize) / 2;
final float currentScale = selectedImageView.getScaleX();
final float currentTranslation = selectedImageView.getTranslationX();
final Animation animation = new Animation() {
@Override protected void applyTransformation(float t, Transformation transformation) {
ViewCompat.setScaleX(selectedImageView, (DEFAULT_SCALE - currentScale) * t + currentScale);
ViewCompat.setTranslationX(selectedImageView,
(target - currentTranslation) * t + currentTranslation);
}
};
animation.setAnimationListener(animationListener);
animation.setDuration(shortAnimDuration);
animation.setInterpolator(ACCELERATE_DECELERATE_INTERPOLATOR);
selectedImageView.clearAnimation();
selectedImageView.startAnimation(animation);
}
代码示例来源:origin: fafaldo/FABToolbar
final int yDelta = yDest - fabConPos[1];
ObjectAnimator xAnimR = ObjectAnimator.ofFloat(fab, "translationX", fab.getTranslationX(), fab.getTranslationX() + xDelta);
ObjectAnimator yAnimR = ObjectAnimator.ofFloat(fabContainer, "translationY", fabContainer.getTranslationY(), fabContainer.getTranslationY() + yDelta);
代码示例来源:origin: fafaldo/FABToolbar
final int yDelta = toolbarPos.y - fabConPos[1];
ObjectAnimator xAnim = ObjectAnimator.ofFloat(fab, "translationX", fab.getTranslationX(), fab.getTranslationX() + xDelta);
ObjectAnimator yAnim = ObjectAnimator.ofFloat(fabContainer, "translationY", fabContainer.getTranslationY(), fabContainer.getTranslationY() + yDelta);
代码示例来源: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
/**
* 处理结束下拉退出的手指事件,进行退出图片查看或者恢复到初始状态的收尾动画<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();
}
}
内容来源于网络,如有侵权,请联系作者删除!