当前位置: 首页>>代码示例>>Java>>正文


Java View.getTranslationY方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:rumaan,项目名称:AcademApp,代码行数:40,代码来源:MaterialIn.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:FloatLayoutHelper.java

示例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);
    }

}
 
开发者ID:zuoni1018,项目名称:CoordinatorLayoutExample-master,代码行数:17,代码来源:UcNewsHeaderPagerBehavior.java

示例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;
}
 
开发者ID:alibaba,项目名称:Tangram-Android,代码行数:23,代码来源:SwipeItemTouchListener.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:ViewPropertyAnimatorHC.java

示例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");
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:41,代码来源:StickyHeaderHelper.java

示例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);
        }

    }
 
开发者ID:pop1234o,项目名称:BestPracticeApp,代码行数:51,代码来源:SwipeCardLayout.java

示例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;
}
 
开发者ID:akashdeepsingh9988,项目名称:Cybernet-VPN,代码行数:8,代码来源:ElasticDrawer.java

示例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();
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:8,代码来源:ViewProxy.java

示例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;
}
 
开发者ID:Othershe,项目名称:BehaviorDemo,代码行数:8,代码来源:XiamiCommentBehavior.java

示例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();
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:8,代码来源:ViewHelper.java

示例12: getTranslationY

import android.view.View; //导入方法依赖的package包/类
/**
 * 获取TranslationY
 *
 * @return
 */
public float getTranslationY() {
    final View view = getView();
    if (view != null) {
        return view.getTranslationY();
    }
    return 0;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:13,代码来源:UDView.java

示例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;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:14,代码来源:PositionAndSizeAnimation.java

示例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));
    }

}
 
开发者ID:Learzhu,项目名称:UcMainPagerDemo-master,代码行数:16,代码来源:UcNewsTitleBehavior.java

示例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);
        }
    }
}
 
开发者ID:Genius,项目名称:genius-groupie,代码行数:43,代码来源:DebugItemDecoration.java


注:本文中的android.view.View.getTranslationY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。