本文整理汇总了Java中android.view.View.setTranslationX方法的典型用法代码示例。如果您正苦于以下问题:Java View.setTranslationX方法的具体用法?Java View.setTranslationX怎么用?Java View.setTranslationX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setTranslationX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createShowItemAnimator
import android.view.View; //导入方法依赖的package包/类
private Animator createShowItemAnimator(View item) {
float dx = fab.getX() - item.getX();
float dy = fab.getY() - item.getY();
item.setRotation(0f);
item.setTranslationX(dx);
item.setTranslationY(dy);
Animator anim = ObjectAnimator.ofPropertyValuesHolder(
item,
// AnimatorUtils.rotation(0f, 720f),
AnimatorUtils.translationX(dx, 0f),
AnimatorUtils.translationY(dy, 0f)
);
return anim;
}
示例2: transformPage
import android.view.View; //导入方法依赖的package包/类
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
if (position < -1) { // [-Infinity,-1)
view.setAlpha(0);
} else if (position <= 0) { // [-1,0]
view.setAlpha(1);
view.setTranslationX(0);
view.setScaleX(1);
view.setScaleY(1);
} else if (position <= 1) { // (0,1]
view.setAlpha(1 - position);
view.setTranslationX(pageWidth * -position);
float scaleFactor = MIN_SCALE
+ (1 - MIN_SCALE) * (1 - Math.abs(position));
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
} else { // (1,+Infinity]
view.setAlpha(0);
}
}
示例3: onPreTransform
import android.view.View; //导入方法依赖的package包/类
/**
* Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
* <p>
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
* alpha.
*
* @param page
* Apply the transformation to this page
* @param position
* Position of page relative to the current front-and-center position of the pager. 0 is front and
* center. 1 is one full page position to the right, and -1 is one page position to the left.
*/
protected void onPreTransform(View page, float position) {
final float width = page.getWidth();
page.setRotationX(0);
page.setRotationY(0);
page.setRotation(0);
page.setScaleX(1);
page.setScaleY(1);
page.setPivotX(0);
page.setPivotY(0);
page.setTranslationY(0);
page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
if (hideOffscreenPages()) {
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
// page.setEnabled(false);
} else {
// page.setEnabled(true);
page.setAlpha(1f);
}
}
示例4: onTransform
import android.view.View; //导入方法依赖的package包/类
protected void onTransform(View view, float position) {
float scale = 1.0f + Math.abs(position);
view.setScaleX(scale);
view.setScaleY(scale);
view.setPivotX(((float) view.getWidth()) * 0.5f);
view.setPivotY(((float) view.getHeight()) * 0.5f);
float f = (position < -1.0f || position > 1.0f) ? 0.0f : 1.0f - (scale - 1.0f);
view.setAlpha(f);
if (position == -1.0f) {
view.setTranslationX((float) (view.getWidth() * -1));
}
}
示例5: onPreTransform
import android.view.View; //导入方法依赖的package包/类
/**
* Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)}.
* <p>
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
* alpha.
*
* @param page
* Apply the transformation to this page
* @param position
* Position of page relative to the current front-and-center position of the pager. 0 is front and
* center. 1 is one full page position to the right, and -1 is one page position to the left.
*/
protected void onPreTransform(View page, float position) {
final float width = page.getWidth();
page.setRotationX(0);
page.setRotationY(0);
page.setRotation(0);
page.setScaleX(1);
page.setScaleY(1);
page.setPivotX(0);
page.setPivotY(0);
page.setTranslationY(0);
page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
if (hideOffscreenPages()) {
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
} else {
page.setAlpha(1f);
}
}
示例6: onTransform
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
final float rotation = (position < 0 ? 30f : -30f) * Math.abs(position);
view.setTranslationX(getOffsetXForRotation(rotation, view.getWidth(), view.getHeight()));
view.setPivotX(view.getWidth() * 0.5f);
view.setPivotY(0);
view.setRotationY(rotation);
}
示例7: showPromoView
import android.view.View; //导入方法依赖的package包/类
/**
* Shows the Promo Android View. By making the Android View visible, we are allowing the
* Promo to be interactive. Since snapshots are not interactive (they are just a bitmap),
* we need to temporarily show the Android View on top of the snapshot, so the user will
* be able to click in the Promo buttons and/or link.
*/
private void showPromoView() {
float y = getYPx();
View view = getView();
if (view == null
|| !mIsVisible
|| (mIsShowingView && mPromoViewY == y)
|| mHeightPx == 0.f) return;
float offsetX = mOverlayPanel.getOffsetX() * mDpToPx;
if (LocalizationUtils.isLayoutRtl()) {
offsetX = -offsetX;
}
view.setTranslationX(offsetX);
view.setTranslationY(y);
view.setVisibility(View.VISIBLE);
// NOTE(pedrosimonetti): We need to call requestLayout, otherwise
// the Promo View will not become visible.
view.requestLayout();
mIsShowingView = true;
mPromoViewY = y;
// The Promo can only be interacted when the View is being displayed.
mWasInteractive = true;
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:34,代码来源:ContextualSearchPromoControl.java
示例8: onTransform
import android.view.View; //导入方法依赖的package包/类
protected void onTransform(View view, float position) {
float rotation = (position < 0.0f ? 30.0f : -30.0f) * Math.abs(position);
view.setTranslationX(getOffsetXForRotation(rotation, view.getWidth(), view.getHeight()));
view.setPivotX(((float) view.getWidth()) * 0.5f);
view.setPivotY(0.0f);
view.setRotationY(rotation);
}
示例9: resetTransformProperty
import android.view.View; //导入方法依赖的package包/类
private static void resetTransformProperty(View view) {
view.setTranslationX(PixelUtil.toPixelFromDIP(0));
view.setTranslationY(PixelUtil.toPixelFromDIP(0));
view.setRotation(0);
view.setRotationX(0);
view.setRotationY(0);
view.setScaleX(1);
view.setScaleY(1);
view.setCameraDistance(0);
}
示例10: onTransform
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
final float scale = 1f + Math.abs(position);
view.setScaleX(scale);
view.setScaleY(scale);
view.setPivotX(view.getWidth() * 0.5f);
view.setPivotY(view.getHeight() * 0.5f);
view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
if (position == -1) {
view.setTranslationX(view.getWidth() * -1);
}
}
示例11: transformPage
import android.view.View; //导入方法依赖的package包/类
public void transformPage(@NonNull View view, float position) {
int pageWidth = view.getWidth();
int pageHeight = view.getHeight();
if (position < -1) { // [-Infinity,-1)
// This page is way off-screen to the left.
view.setAlpha(0);
} else if (position <= 1) { // [-1,1]
// Modify the default slide transition to shrink the page as well
float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
float vertMargin = pageHeight * (1 - scaleFactor) / 2;
float horzMargin = pageWidth * (1 - scaleFactor) / 2;
if (position < 0) {
view.setTranslationX(horzMargin - vertMargin / 2);
} else {
view.setTranslationX(-horzMargin + vertMargin / 2);
}
// Scale the page down (between MIN_SCALE and 1)
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
// Fade the page relative to its size.
view.setAlpha(MIN_ALPHA +
(scaleFactor - MIN_SCALE) /
(1 - MIN_SCALE) * (1 - MIN_ALPHA));
} else { // (1,+Infinity]
// This page is way off-screen to the right.
view.setAlpha(0);
}
}
示例12: onTransform
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
if (position >= -1 || position <= 1) {
// Modify the default slide transition to shrink the page as well
final float height = view.getHeight();
final float width = view.getWidth();
final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
final float vertMargin = height * (1 - scaleFactor) / 2;
final float horzMargin = width * (1 - scaleFactor) / 2;
// Center vertically
view.setPivotY(0.5f * height);
view.setPivotX(0.5f * width);
if (position < 0) {
view.setTranslationX(horzMargin - vertMargin / 2);
} else {
view.setTranslationX(-horzMargin + vertMargin / 2);
}
// Scale the page down (between MIN_SCALE and 1)
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
// Fade the page relative to its size.
view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
}
}
示例13: transformPageDepth
import android.view.View; //导入方法依赖的package包/类
private void transformPageDepth(View view, float position) {
final float MIN_SCALE = 0.75f;
int pageWidth = view.getWidth();
if (position < -1) { // [-Infinity,-1)
// This page is way off-screen to the left.
view.setAlpha(0);
} else if (position <= 0) { // [-1,0]
// Use the default slide transition when moving to the left page
view.setAlpha(1);
view.setTranslationX(0);
view.setScaleX(1);
view.setScaleY(1);
} else if (position <= 1) { // (0,1]
// Fade the page out.
view.setAlpha(1 - position);
// Counteract the default slide transition
view.setTranslationX(pageWidth * -position);
// Scale the page down (between MIN_SCALE and 1)
float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
} else { // (1,+Infinity]
// This page is way off-screen to the right.
view.setAlpha(0);
}
}
示例14: transformPage
import android.view.View; //导入方法依赖的package包/类
@Override
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
int pageHeight = view.getHeight();
float alpha = 0;
if (0 <= position && position <= 1) {
alpha = 1 - position;
} else if (-1 < position && position < 0) {
float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
float verticalMargin = pageHeight * (1 - scaleFactor) / 2;
float horizontalMargin = pageWidth * (1 - scaleFactor) / 2;
if (position < 0) {
view.setTranslationX(horizontalMargin - verticalMargin / 2);
} else {
view.setTranslationX(-horizontalMargin + verticalMargin / 2);
}
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
alpha = position + 1;
}
view.setAlpha(alpha);
view.setTranslationX(view.getWidth() * -position);
float yPosition = position * view.getHeight();
view.setTranslationY(yPosition);
}
示例15: setTranslation
import android.view.View; //导入方法依赖的package包/类
/**
* 设置Translation X, Y
*
* @param tx
* @param ty
* @return
*/
public UDView setTranslation(Float tx, Float ty) {
final View view = getView();
if (view != null) {
if (tx != null) {
view.setTranslationX(tx);
}
if (ty != null) {
view.setTranslationY(ty);
}
}
return this;
}