本文整理汇总了Java中android.view.View.getTranslationY方法的典型用法代码示例。如果您正苦于以下问题:Java View.getTranslationY方法的具体用法?Java View.getTranslationY怎么用?Java View.getTranslationY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.getTranslationY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startAnimators
import android.view.View; //导入方法依赖的package包/类
public static void startAnimators(final View view, int startOffsetX, int startOffsetY, long delay) {
if (view.getVisibility() == View.VISIBLE && view.getAlpha() != 0f) {
view.clearAnimation();
view.animate().cancel();
final Resources res = view.getResources();
final float endAlpha = view.getAlpha();
final float endTranslateX = view.getTranslationX();
final float endTranslateY = view.getTranslationY();
view.setAlpha(0);
final Animator fade = ObjectAnimator.ofFloat(view, View.ALPHA, endAlpha);
fade.setDuration(res.getInteger(R.integer.material_in_fade_anim_duration));
fade.setInterpolator(new AccelerateInterpolator());
fade.setStartDelay(delay);
fade.start();
ViewPropertyAnimator slide = view.animate();
if (startOffsetY != 0) {
view.setTranslationY(startOffsetY);
slide.translationY(endTranslateY);
} else {
view.setTranslationX(startOffsetX);
slide.translationX(endTranslateX);
}
slide.setInterpolator(new DecelerateInterpolator(2));
slide.setDuration(res.getInteger(R.integer.material_in_slide_anim_duration));
slide.setStartDelay(delay);
slide.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
if (fade.isStarted()) {
fade.cancel();
}
view.setAlpha(endAlpha);
view.setTranslationX(endTranslateX);
view.setTranslationY(endTranslateY);
}
});
slide.start();
}
}
示例2: doPullOverAnimation
import android.view.View; //导入方法依赖的package包/类
private void doPullOverAnimation(final View v) {
ObjectAnimator animator;
if (v.getTranslationX() + v.getWidth() / 2 + v.getLeft() > parentViewWidth / 2) {
animator = ObjectAnimator.ofFloat(v, "translationX",
v.getTranslationX(), parentViewWidth - v.getWidth()
- v.getLeft() - rightMargin - mAdjuster.right);
mTransitionX = parentViewWidth - v.getWidth() - v.getLeft() - rightMargin - mAdjuster.right;
} else {
animator = ObjectAnimator.ofFloat(v, "translationX",
v.getTranslationX(), -v.getLeft() + leftMargin + mAdjuster.left);
mTransitionX = -v.getLeft() + leftMargin + mAdjuster.left;
}
mTransitionY = (int) v.getTranslationY();
animator.setDuration(200);
animator.start();
}
示例3: handleActionUp
import android.view.View; //导入方法依赖的package包/类
private void handleActionUp(CoordinatorLayout parent, final View child) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "handleActionUp: ");
}
if (mFlingRunnable != null) {
child.removeCallbacks(mFlingRunnable);
mFlingRunnable = null;
}
mFlingRunnable = new FlingRunnable(parent, child);
if (child.getTranslationY() < getHeaderOffsetRange() / 3.0f) {
mFlingRunnable.scrollToClosed(DURATION_SHORT);
} else {
mFlingRunnable.scrollToOpen(DURATION_SHORT);
}
}
示例4: findScrollableChildViewUnder
import android.view.View; //导入方法依赖的package包/类
private View findScrollableChildViewUnder(MotionEvent event) {
final int x = (int) event.getX();
final int y = (int) event.getY();
final int first = getLayoutManager().findFirstVisibleItemPosition();
final int last = getLayoutManager().findLastVisibleItemPosition();
for (int i = 0; i <= last - first; i++) {
View child = getLayoutManager().getChildAt(i);
if (child instanceof ViewGroup) {
float translationX = child.getTranslationX();
float translationY = child.getTranslationY();
if (x >= (float) child.getLeft() + translationX
&& x <= (float) child.getRight() + translationX
&& y >= (float) child.getTop() + translationY
&& y <= (float) child.getBottom() + translationY) {
if (findCanScrollView(child) != null) {
return child;
}
}
}
}
return null;
}
示例5: getValue
import android.view.View; //导入方法依赖的package包/类
private float getValue(int propertyConstant) {
View v = (View) this.mView.get();
if (v != null) {
switch (propertyConstant) {
case 1:
return v.getTranslationX();
case 2:
return v.getTranslationY();
case 4:
return v.getScaleX();
case 8:
return v.getScaleY();
case 16:
return v.getRotation();
case 32:
return v.getRotationX();
case 64:
return v.getRotationY();
case 128:
return v.getX();
case 256:
return v.getY();
case 512:
return v.getAlpha();
}
}
return 0.0f;
}
示例6: showSticky
import android.view.View; //导入方法依赖的package包/类
/**
* Bring component with bigest pos to Front
*/
private void showSticky() {
if(mCurrentStickyRef==null){
WXLogUtils.e("Current Sticky ref is null.");
return;
}
WXCell headComponent = mHeaderComps.get(mCurrentStickyRef);
final View headerView = headComponent.getRealView();
if (headerView == null) {
WXLogUtils.e("Sticky header's real view is null.");
return;
}
View header = mHeaderViews.get(headComponent.getRef());
if( header != null){
//already there
header.bringToFront();
}else {
mHeaderViews.put(headComponent.getRef(), headerView);
//record translation, it should not change after transformation
final float translationX = headerView.getTranslationX();
final float translationY = headerView.getTranslationY();
headComponent.removeSticky();
ViewGroup existedParent;
if ((existedParent = (ViewGroup) headerView.getParent()) != null) {
existedParent.removeView(headerView);
}
mParent.addView(headerView);
//recover translation, sometimes it will be changed on fling
headerView.setTranslationX(translationX);
headerView.setTranslationY(translationY);
}
if (headComponent.getDomObject().getEvents().contains("sticky")) {
headComponent.fireEvent("sticky");
}
}
示例7: onDraw
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// Log.i(TAG, "onDraw: " + x + " " + y);
float width = getWidth() / 2.0f;
float height = getHeight() / 2.0f;
View childAt = getChildAt(0);
//画固定底片
if (adapter.tQueue.size() > 1) {
float s_width1 = childAt.getWidth() * mScale;
float s_height1 = childAt.getHeight() * mScale;
float dx1 = (s_width1 - s_width1 * mScale) / 2;
float l1 = width - s_width1 / 2 + dx1;
float t1 = height + s_height1 / 2 + mTranslate;
float r1 = width + s_width1 / 2 - dx1;
float b1 = t1 + mDy;
rect.left = l1;
rect.top = t1 - 20 * density;
rect.right = r1;
rect.bottom = b1;
canvas.drawRoundRect(rect, round, round, paint);
canvas.drawRoundRect(rect, round, round, paint_s);
}
if (adapter.tQueue.size() > 0) {
float scaleX = childAt.getScaleX();
float s_width = childAt.getWidth() * scaleX;
float s_height = childAt.getHeight() * scaleX;
float dx = (s_width - s_width * mScale) / 2;
float l = width - s_width / 2 + dx;
float t = height + s_height / 2 + childAt.getTranslationY();
float r = width + s_width / 2 - dx;
float b = t + mDy;
rect.left = l;
rect.top = t - 20 * density;
rect.right = r;
rect.bottom = b;
canvas.drawRoundRect(rect, round, round, paint);
canvas.drawRoundRect(rect, round, round, paint_s);
}
}
示例8: supportGetTranslationY
import android.view.View; //导入方法依赖的package包/类
private int supportGetTranslationY(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return (int) v.getTranslationY();
}
return 0;
}
示例9: getTranslationY
import android.view.View; //导入方法依赖的package包/类
public static float getTranslationY(View view) {
if (View10.NEED_PROXY) {
return View10.wrap(view).getTranslationY();
} else {
return view.getTranslationY();
}
}
示例10: onDependentViewChanged
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
float commentScrollY = dependency.getTranslationY() / getHeaderOffset() * (dependency.getHeight() - getTitleHeight());
float y = dependency.getHeight() - commentScrollY;
child.setY(y);
return true;
}
示例11: getBottom
import android.view.View; //导入方法依赖的package包/类
public static int getBottom(View v) {
if (MenuDrawer.USE_TRANSLATIONS) {
return (int) (v.getBottom() + v.getTranslationY());
}
return v.getBottom();
}
示例12: getTranslationY
import android.view.View; //导入方法依赖的package包/类
/**
* 获取TranslationY
*
* @return
*/
public float getTranslationY() {
final View view = getView();
if (view != null) {
return view.getTranslationY();
}
return 0;
}
示例13: PositionAndSizeAnimation
import android.view.View; //导入方法依赖的package包/类
public PositionAndSizeAnimation(View view, int x, int y, int width, int height) {
mView = view;
mStartX = view.getX() - view.getTranslationX();
mStartY = view.getY() - view.getTranslationY();
mStartWidth = view.getWidth();
mStartHeight = view.getHeight();
mDeltaX = x - mStartX;
mDeltaY = y - mStartY;
mDeltaWidth = width - mStartWidth;
mDeltaHeight = height - mStartHeight;
}
示例14: offsetChildAsNeeded
import android.view.View; //导入方法依赖的package包/类
private void offsetChildAsNeeded(CoordinatorLayout parent, View child, View dependency) {
int headerOffsetRange = getHeaderOffsetRange();
int titleOffsetRange = getTitleHeight();
if (BuildConfig.DEBUG) {
Log.d(TAG, "offsetChildAsNeeded:" + dependency.getTranslationY());
}
if (dependency.getTranslationY() == headerOffsetRange) {
child.setTranslationY(titleOffsetRange);
} else if (dependency.getTranslationY() == 0) {
child.setTranslationY(0);
} else {
child.setTranslationY((int) (dependency.getTranslationY() / (headerOffsetRange * 1.0f) * titleOffsetRange));
}
}
示例15: onDrawOver
import android.view.View; //导入方法依赖的package包/类
@Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
if (!(prefs.getShowBounds() || prefs.getShowOffsets())) return;
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = parent.getChildAt(i);
RecyclerView.LayoutManager lm = parent.getLayoutManager();
decoratedLeft = lm.getDecoratedLeft(child) + (int) child.getTranslationX();
decoratedTop = lm.getDecoratedTop(child) + (int) child.getTranslationY();
decoratedRight = lm.getDecoratedRight(child) + (int) child.getTranslationX();
decoratedBottom = lm.getDecoratedBottom(child) + (int) child.getTranslationY();
left = child.getLeft() + (int) child.getTranslationX();
top = child.getTop() + (int) child.getTranslationY();
right = child.getRight() + (int) child.getTranslationX();
bottom = child.getBottom() + (int) child.getTranslationY();
if (prefs.getShowBounds()) {
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
c.drawRect(decoratedLeft, decoratedTop, decoratedRight, decoratedBottom, paint);
}
if (prefs.getShowOffsets()) {
paint.setStyle(Paint.Style.FILL);
paint.setColor(leftColor);
c.drawRect(decoratedLeft, decoratedTop, left, decoratedBottom, paint);
paint.setColor(topColor);
c.drawRect(decoratedLeft, decoratedTop, decoratedRight, top, paint);
paint.setColor(rightColor);
c.drawRect(right, decoratedTop, decoratedRight, decoratedBottom, paint);
paint.setColor(bottomColor);
c.drawRect(decoratedLeft, bottom, decoratedRight, decoratedBottom, paint);
}
}
}