本文整理了Java中android.widget.ImageView.setTranslationX()
方法的一些代码示例,展示了ImageView.setTranslationX()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setTranslationX()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:setTranslationX
暂无
代码示例来源:origin: stephentuso/welcome-android
@Override
public void onWelcomeScreenPageScrolled(int pageIndex, float offset, int offsetPixels) {
if (showParallaxAnim && Build.VERSION.SDK_INT >= 11 && imageView != null) {
imageView.setTranslationX(-offsetPixels * 0.8f);
}
}
代码示例来源:origin: stephentuso/welcome-android
@Override
public void onWelcomeScreenPageScrolled(int pageIndex, float offset, int offsetPixels) {
if (showParallaxAnim && Build.VERSION.SDK_INT >= 11 && imageView != null) {
imageView.setTranslationX(-offsetPixels * 0.8f);
}
}
代码示例来源:origin: Ramotion/expanding-collection-android
public View makeView() {
ImageView myView = new ImageView(context);
myView.setScaleType(ImageView.ScaleType.CENTER_CROP);
myView.setLayoutParams(new FrameLayout.LayoutParams(bgImageWidth, FrameLayout.LayoutParams.MATCH_PARENT));
myView.setTranslationX(-bgImageGap);
return myView;
}
});
代码示例来源:origin: liaoinstan/SpringView
private void reset() {
hasOverSpringHeight = false;
img_dot1.setTranslationX(0);
img_dot3.setTranslationX(0);
lay_dot.setTranslationY(0);
lay_dot.setAlpha(1f);
}
代码示例来源:origin: north2016/T-MVP
void backwards(int position, float positionOffset) {
if (isSkip) return;
// Log.e("DEBUG-WCL", "backwards-positionOffset: " + positionOffset);
int width = mTargetImage.getWidth();
mOutgoingImage.setTranslationX((1 - positionOffset) * (FACTOR * width));
mTargetImage.setTranslationX(-(positionOffset) * (FACTOR * width));
int color = BaseUtils.evaluate(1 - positionOffset, mColors[position + 1], mColors[position]);
collapsingToolbar.setContentScrimColor(color);
collapsingToolbar.setStatusBarScrimColor(color);
mTargetImage.setAlpha(1 - positionOffset);
}
代码示例来源:origin: north2016/T-MVP
void forward(int position, float positionOffset) {
if (isSkip) return;
// Log.e("DEBUG-WCL", "forward-positionOffset: " + positionOffset);
int width = mTargetImage.getWidth();
mOutgoingImage.setTranslationX(-positionOffset * (FACTOR * width));
mTargetImage.setTranslationX((1 - positionOffset) * (FACTOR * width));
int color = BaseUtils.evaluate(positionOffset, mColors[position], mColors[position + 1]);
collapsingToolbar.setContentScrimColor(color);
collapsingToolbar.setStatusBarScrimColor(color);
mTargetImage.setAlpha(positionOffset);
}
代码示例来源:origin: ZieIony/Carbon
@Override
public void setTranslationX(float translationX) {
super.setTranslationX(translationX);
invalidateParentIfNeeded();
fireOnTransformationChangedListener();
}
代码示例来源:origin: north2016/T-MVP
/**
* 启动动画, 之后选择向前或向后滑动
*
* @param startPosition 起始位置
* @param endPosition 终止位置
*/
public void start(int startPosition, int endPosition) {
if (Math.abs(endPosition - startPosition) > 1) {
isSkip = true;
}
mActualStart = startPosition;
Log.e("DEBUG", "startPosition: " + startPosition + ", endPosition: " + endPosition);
// 终止位置的图片
//@DrawableRes int incomeId = ids[endPosition % ids.length];
// 原始图片
mOutgoingImage.setImageDrawable(mTargetImage.getDrawable()); // 原始的图片
// 起始图片
mOutgoingImage.setTranslationX(0f);
mOutgoingImage.setVisibility(View.VISIBLE);
mOutgoingImage.setAlpha(1.0f);
// 目标图片
// mTargetImage.setImageResource(incomeId);
BindingUtils.loadImg(mTargetImage, mImages[endPosition]);
mStart = Math.min(startPosition, endPosition);
mEnd = Math.max(startPosition, endPosition);
}
代码示例来源:origin: north2016/T-MVP
/**
* 滑动结束的动画效果
*
* @param endPosition 滑动位置
*/
public void end(int endPosition) {
isSkip = false;
//@DrawableRes int incomeId = ids[endPosition % ids.length];
Log.e("DEBUG", "endPosition: " + endPosition);
mTargetImage.setTranslationX(0f);
// 设置原始图片
if (endPosition == mActualStart) {
mTargetImage.setImageDrawable(mOutgoingImage.getDrawable());
} else {
BindingUtils.loadImg(mTargetImage, mImages[endPosition]);
collapsingToolbar.setContentScrimColor(mColors[endPosition]);
collapsingToolbar.setStatusBarScrimColor(mColors[endPosition]);
//mTargetImage.setImageResource(incomeId);
mTargetImage.setAlpha(1f);
mOutgoingImage.setVisibility(View.GONE);
}
}
代码示例来源:origin: arimorty/floatingsearchview
private void handleOnVisibleMenuItemsWidthChanged(int menuItemsWidth) {
if (menuItemsWidth == 0) {
mClearButton.setTranslationX(-Util.dpToPx(4));
int paddingRight = Util.dpToPx(4);
if (mIsFocused) {
paddingRight += Util.dpToPx(CLEAR_BTN_WIDTH_DP);
} else {
paddingRight += Util.dpToPx(14);
}
mSearchInput.setPadding(0, 0, paddingRight, 0);
} else {
mClearButton.setTranslationX(-menuItemsWidth);
int paddingRight = menuItemsWidth;
if (mIsFocused) {
paddingRight += Util.dpToPx(CLEAR_BTN_WIDTH_DP);
}
mSearchInput.setPadding(0, 0, paddingRight, 0);
}
}
代码示例来源:origin: liaoinstan/SpringView
img_dot1.setTranslationX(-nowSpace);
img_dot3.setTranslationX(nowSpace);
代码示例来源:origin: arimorty/floatingsearchview
mLeftAction.setScaleY(0.5f);
mLeftAction.setAlpha(0.0f);
mLeftAction.setTranslationX(Util.dpToPx(8));
ObjectAnimator transXArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).translationX(1.0f).get();
ObjectAnimator scaleXArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleX(1.0f).get();
代码示例来源:origin: stackoverflow.com
final ImageView backgroundOne = (ImageView) findViewById(R.id.background_one);
final ImageView backgroundTwo = (ImageView) findViewById(R.id.background_two);
final ValueAnimator animator = ValueAnimator.ofFloat(0.0f, 1.0f);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.setInterpolator(new LinearInterpolator());
animator.setDuration(10000L);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final float progress = (float) animation.getAnimatedValue();
final float width = backgroundOne.getWidth();
final float translationX = width * progress;
backgroundOne.setTranslationX(translationX);
backgroundTwo.setTranslationX(translationX - width);
}
});
animator.start();
代码示例来源:origin: iielse/ImageWatcher
translateXValue = -translateXEdge + (translateXValue - (-translateXEdge)) * edgeResilience;
iSource.setTranslationX(translateXValue);
} else if ("vertical".equals(imageOrientation)) {
if (vsDefault.width * vsTouchDrag.scaleX <= mWidth) {
iSource.setTranslationX(translateXValue);
代码示例来源:origin: iielse/ImageWatcher
float changedCenterXValue = vsTouchScale.translationX - changedCenterX;
float fitTransX = 0; // to do 缩放中心修正~
iSource.setTranslationX(changedCenterXValue + fitTransX);
float changedCenterY = mFingersCenterY - centerY;
float changedCenterYValue = vsTouchScale.translationY - changedCenterY;
代码示例来源:origin: iielse/ImageWatcher
iPicture.setBackgroundResource(R.drawable.default_picture);
Glide.with(getContext()).load(thumbList.get(i)).into(iPicture);
iPicture.setTranslationX((i % column) * (imageSize + mSpace));
iPicture.setTranslationY((i / column) * (imageSize + mSpace));
} else {
代码示例来源:origin: iielse/ImageWatcher
/**
* 处理响应退出图片查看
*/
private void handleExitGesture(MotionEvent e2, MotionEvent e1) {
if (iSource == null) return;
ViewState vsExit = ViewState.read(iSource, ViewState.STATE_EXIT);
ViewState vsDefault = ViewState.read(iSource, ViewState.STATE_DEFAULT);
if (vsExit == null || vsDefault == null) return;
mExitRef = 1;
final float moveY = e2.getY() - e1.getY();
final float moveX = e2.getX() - e1.getX();
if (moveY > 0) mExitRef -= moveY / (mHeight / 2);
if (mExitRef < 0) mExitRef = 0;
setBackgroundColor(mColorEvaluator.evaluate(mExitRef, 0x00000000, 0xFF000000));
final float exitScale = MIN_SCALE + (vsExit.scaleX - MIN_SCALE) * mExitRef;
iSource.setScaleX(exitScale);
iSource.setScaleY(exitScale);
final float exitTrans = vsDefault.translationX + (vsExit.translationX - vsDefault.translationX) * mExitRef;
iSource.setTranslationX(exitTrans + moveX);
iSource.setTranslationY(vsExit.translationY + moveY);
}
代码示例来源:origin: iielse/ImageWatcher
final int[] location = new int[2];
originRef.getLocationOnScreen(location);
imageView.setTranslationX(location[0]);
int locationYOfFullScreen = location[1];
locationYOfFullScreen -= mStatusBarHeight;
代码示例来源:origin: kot32go/KSimpleLibrary
@Override
public void loadTips(View headerView, int progress) {
float scaleRatio = ((float) progress) / 100;
people.setScaleX(scaleRatio);
people.setScaleY(scaleRatio);
box.setScaleX(scaleRatio);
box.setScaleY(scaleRatio);
people.setTranslationX(tx * scaleRatio);
box.setTranslationY(ty * scaleRatio);
tips.setText("上拉加载...");
frameAnimation.stop();
}
代码示例来源:origin: kot32go/KSimpleLibrary
@Override
public void pullingTips(View headerView, int progress) {
float scaleRatio = ((float) progress) / 100;
people.setScaleX(scaleRatio);
people.setScaleY(scaleRatio);
box.setScaleX(scaleRatio);
box.setScaleY(scaleRatio);
people.setTranslationX(tx * scaleRatio);
box.setTranslationY(ty * scaleRatio);
tips.setText("下拉更新...");
frameAnimation.stop();
}
内容来源于网络,如有侵权,请联系作者删除!