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


Java View.getX方法代码示例

本文整理汇总了Java中android.view.View.getX方法的典型用法代码示例。如果您正苦于以下问题:Java View.getX方法的具体用法?Java View.getX怎么用?Java View.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createShowItemAnimator

import android.view.View; //导入方法依赖的package包/类
private Animator createShowItemAnimator(View item) {
  float dx = centerItem.getX() - item.getX();
  float dy = centerItem.getY() - item.getY();

  item.setScaleX(0f);
  item.setScaleY(0f);
  item.setTranslationX(dx);
  item.setTranslationY(dy);

  Animator anim = ObjectAnimator.ofPropertyValuesHolder(
      item,
      AnimatorUtils.scaleX(0f, 1f),
      AnimatorUtils.scaleY(0f, 1f),
      AnimatorUtils.translationX(dx, 0f),
      AnimatorUtils.translationY(dy, 0f)
  );

  anim.setInterpolator(new DecelerateInterpolator());
  anim.setDuration(50);
  return anim;
}
 
开发者ID:xzg8023,项目名称:ArcLayout-master,代码行数:22,代码来源:DemoLikeTumblrActivity.java

示例2: createHideItemAnimator

import android.view.View; //导入方法依赖的package包/类
private Animator createHideItemAnimator(final View item) {
  final float dx = centerItem.getX() - item.getX();
  final float dy = centerItem.getY() - item.getY();

  Animator anim = ObjectAnimator.ofPropertyValuesHolder(
      item,
      AnimatorUtils.scaleX(1f, 0f),
      AnimatorUtils.scaleY(1f, 0f),
      AnimatorUtils.translationX(0f, dx),
      AnimatorUtils.translationY(0f, dy)
  );

  anim.setInterpolator(new DecelerateInterpolator());
  anim.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      super.onAnimationEnd(animation);
      item.setTranslationX(0f);
      item.setTranslationY(0f);
    }
  });
  anim.setDuration(50);
  return anim;
}
 
开发者ID:xzg8023,项目名称:ArcLayout-master,代码行数:25,代码来源:DemoLikeTumblrActivity.java

示例3: calcScrollInfo

import android.view.View; //导入方法依赖的package包/类
private ScrollInfo calcScrollInfo(View movingView) {
    ScrollInfo result = new ScrollInfo();
    float dx = movingView.getX() - mChildInitX;
    float dy = movingView.getY() - mChildInitY;
    int direction;
    if (Float.compare(dx, 0) == 0 && Float.compare(dy, 0) == 0) {
        direction = StackCardsView.SWIPE_NONE;
    } else {
        if (Math.abs(dx) * SLOPE > Math.abs(dy)) {
            direction = dx > 0 ? StackCardsView.SWIPE_RIGHT : StackCardsView.SWIPE_LEFT;
        } else {
            direction = dy > 0 ? StackCardsView.SWIPE_DOWN : StackCardsView.SWIPE_UP;
        }
    }
    log(TAG, "calcScrollInfo,direction=" + direction + ",dx=" + dx + ",dy=" + dy);
    result.direction = direction;
    double distance = Math.sqrt(dx * dx + dy * dy);
    float dismiss_distance = mSwipeView.getDismissDistance();
    if (distance >= dismiss_distance) {
        result.progress = 1;
    } else {
        result.progress = (float) distance / dismiss_distance;
    }
    return result;
}
 
开发者ID:wensefu,项目名称:StackCardsView,代码行数:26,代码来源:SwipeTouchHelper.java

示例4: createAnimationImpl

import android.view.View; //导入方法依赖的package包/类
@Override
@Nullable Animation createAnimationImpl(View view, int x, int y, int width, int height) {
  boolean animateLocation = view.getX() != x || view.getY() != y;
  boolean animateSize = view.getWidth() != width || view.getHeight() != height;
  if (!animateLocation && !animateSize) {
    return null;
  } else if (animateLocation && !animateSize && USE_TRANSLATE_ANIMATION) {
    // Use GPU-accelerated animation, however we loose the ability to resume interrupted
    // animation where it was left off. We may be able to listen to animation interruption
    // and set the layout manually in this case, so that next animation kicks off smoothly.
    return new TranslateAnimation(view.getX() - x, 0, view.getY() - y, 0);
  } else {
    // Animation is sub-optimal for perf, but scale transformation can't be use in this case.
    return new PositionAndSizeAnimation(view, x, y, width, height);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:LayoutUpdateAnimation.java

示例5: createHideItemAnimator

import android.view.View; //导入方法依赖的package包/类
private Animator createHideItemAnimator(final View item) {
        float dx = fab.getX() - item.getX();
        float dy = fab.getY() - item.getY();

        Animator anim = ObjectAnimator.ofPropertyValuesHolder(
                item,
//                AnimatorUtils.rotation(720f, 0f),
                AnimatorUtils.translationX(0f, dx),
                AnimatorUtils.translationY(0f, dy)
        );

        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                item.setTranslationX(0f);
                item.setTranslationY(0f);
            }
        });

        return anim;
    }
 
开发者ID:xzg8023,项目名称:ArcLayout-master,代码行数:23,代码来源:MainActivity.java

示例6: startAnimation

import android.view.View; //导入方法依赖的package包/类
protected void startAnimation(final int position) {

        float distance = 1;

        View view = mLinearLayoutManager.findViewByPosition(position);
        if (view != null) {
            float currentX = view.getX() + view.getMeasuredWidth() / 2.f;
            float centerX = getMeasuredWidth() / 2.f;
            distance = Math.abs(centerX - currentX) / view.getMeasuredWidth();
        }

        ValueAnimator animator;
        if (position < mIndicatorPosition) {
            animator = ValueAnimator.ofFloat(distance, 0);
        } else {
            animator = ValueAnimator.ofFloat(-distance, 0);
        }
        animator.setDuration(DEFAULT_SCROLL_DURATION);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scrollToTab(position, (float) animation.getAnimatedValue(), true);
            }
        });
        animator.start();
    }
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:27,代码来源:RecyclerTabLayout.java

示例7: onInterceptTouchEvent

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if(PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("widgetScroll", false)) {
        if (ev.getAction() == MotionEvent.ACTION_MOVE || ev.getAction() == MotionEvent.ACTION_SCROLL) {
            if(Math.abs(ev.getX()-lastX)<Math.abs(ev.getY()-lastY)) {
                for (int i = 0; i < getChildCount(); i++) {
                    View v = getChildAt(i);
                    if (v.getTag() instanceof Card.Apps) {
                        Card.Apps c = (Card.Apps) v.getTag();
                        float x = v.getX() + c.getCardContainer().getX();
                        float y = v.getY() + c.getCardContainer().getY();
                        float w = c.getCardContainer().getWidth();
                        float h = c.getCardContainer().getHeight();
                        if (ev.getX() >= x && ev.getX() < x + w && ev.getY() >= y && ev.getY() < y + h) {
                            return true;
                        } else break;
                    }
                }
            }
        }
    }
    lastX = ev.getX();
    lastY = ev.getY();
    return super.onInterceptTouchEvent(ev);
}
 
开发者ID:jathak,项目名称:sflauncher,代码行数:26,代码来源:SuperRecyclerView.java

示例8: updateView

import android.view.View; //导入方法依赖的package包/类
public void updateView(View child, View dependency) {
    float percent = 0;
    float start = 0;
    float current = 0;
    float end = UNSPECIFIED_INT;
    switch (mDependType) {
        case DEPEND_TYPE_WIDTH:
            start = mDependStartWidth;
            current = dependency.getWidth();
            end = mDependTargetWidth;
            break;
        case DEPEND_TYPE_HEIGHT:
            start = mDependStartHeight;
            current = dependency.getHeight();
            end = mDependTargetHeight;
            break;
        case DEPEND_TYPE_X:
            start = mDependStartX;
            current = dependency.getX();
            end = mDependTargetX;
            break;
        case DEPEND_TYPE_Y:
            start = mDependStartY;
            current = dependency.getY();
            end = mDependTargetY;
            break;
    }
    if (end != UNSPECIFIED_INT) {
        percent = Math.abs(current - start) / Math.abs(end - start);
    }
    updateViewWithPercent(child, percent > 1 ? 1 : percent);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:SimpleViewBehavior.java

示例9: getX

import android.view.View; //导入方法依赖的package包/类
public static float getX(View view) {
    if (View10.NEED_PROXY) {
        return View10.wrap(view).getX();
    } else {
        return view.getX();
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:8,代码来源:ViewProxy.java

示例10: getValue

import android.view.View; //导入方法依赖的package包/类
/**
 * This method gets the value of the named property from the View object.
 *
 * @param propertyConstant The property whose value should be returned
 * @return float The value of the named property
 */
private float getValue(int propertyConstant) {
    //final View.TransformationInfo info = mView.mTransformationInfo;
    View v = mView.get();
    if (v != null) {
        switch (propertyConstant) {
            case TRANSLATION_X:
                //return info.mTranslationX;
                return v.getTranslationX();
            case TRANSLATION_Y:
                //return info.mTranslationY;
                return v.getTranslationY();
            case ROTATION:
                //return info.mRotation;
                return v.getRotation();
            case ROTATION_X:
                //return info.mRotationX;
                return v.getRotationX();
            case ROTATION_Y:
                //return info.mRotationY;
                return v.getRotationY();
            case SCALE_X:
                //return info.mScaleX;
                return v.getScaleX();
            case SCALE_Y:
                //return info.mScaleY;
                return v.getScaleY();
            case X:
                //return v.mLeft + info.mTranslationX;
                return v.getX();
            case Y:
                //return v.mTop + info.mTranslationY;
                return v.getY();
            case ALPHA:
                //return info.mAlpha;
                return v.getAlpha();
        }
    }
    return 0;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:46,代码来源:ViewPropertyAnimatorHC.java

示例11: isChildUnder

import android.view.View; //导入方法依赖的package包/类
private static boolean isChildUnder(View child, float x, float y) {
    final float left = child.getX();
    final float top = child.getY();
    final float right = left + child.getWidth();
    final float bottom = top + child.getHeight();
    return x >= left && y >= top && x < right && y < bottom;
}
 
开发者ID:haruue,项目名称:OpenWithX,代码行数:8,代码来源:ResolverDrawerLayout.java

示例12: findListChildUnder

import android.view.View; //导入方法依赖的package包/类
private View findListChildUnder(float x, float y) {
    View v = findChildUnder(x, y);
    while (v != null) {
        x -= v.getX();
        y -= v.getY();
        if (v instanceof RecyclerView/*AbsListView*/) {
            // One more after this.
            return findChildUnder((ViewGroup) v, x, y);
        }
        v = v instanceof ViewGroup ? findChildUnder((ViewGroup) v, x, y) : null;
    }
    return null;
}
 
开发者ID:RikkaW,项目名称:Bridge,代码行数:14,代码来源:ResolverDrawerLayout.java

示例13: swipeOnView

import android.view.View; //导入方法依赖的package包/类
public static void swipeOnView(AppEventOuterClass.UIID uiid, ViewInteraction vi, AppEventOuterClass.Orientation ori){
    switch(ori.getOrientType()){
        case UP: vi.perform(swipeUp()); break;
        case DOWN: vi.perform(swipeDown()); break;
        case LEFT: vi.perform(swipeLeft()); break;
        case RIGHT: vi.perform(swipeRight()); break;
        case XY_TYPE:
            ActivityManager activityManager = new ActivityManager();
            View v = new View(activityManager.getActivityInstance().getApplicationContext());
            switch(uiid.getIdType()){
                case R_ID:
                    v = activityManager.getDecorView().findViewById(uiid.getRid());
                    break;
                case NAME_ID:
                    View decorView = activityManager.getDecorView();
                    int resId = decorView.getResources().getIdentifier(uiid.getNameid(), "id", activityManager.getActivityInstance().getPackageName() );
                    v = decorView.findViewById(resId);
                    break;
            }

            if(v == null) {
                return;
            }

            float x = v.getX();
            float y = v.getY();
            float centerX = x + v.getWidth() / 2;
            float centerY = y + v.getHeight() / 2;
            AppEventOuterClass.XYCoordin desXY = ori.getXy();
            vi.perform(swipeOnCoord(centerX, centerY, desXY.getX(), desXY.getY()));
            
            break;
    }
}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:35,代码来源:FingerGestures.java

示例14: getViewMidPoint

import android.view.View; //导入方法依赖的package包/类
/**
 * 该方法用于回一个View的终点坐标 如果该View不存在则返回(0,0)
 *
 * @param view
 * @return
 */
private Point getViewMidPoint(View view) {
	Point point = new Point();
	if (view != null) {
		float xx = view.getX();
		float yy = view.getY();
		int center_x = (int) (xx + view.getWidth() / 2);
		int center_y = (int) (yy + view.getHeight() / 2);
		point.set(center_x, center_y);
	} else {
		point.set(0, 0);
	}
	return point;
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:20,代码来源:MyRelativeLayout.java

示例15: enter

import android.view.View; //导入方法依赖的package包/类
public static Completable enter(final View view, final int xOffset, final int yOffset) {
    final float startingX = view.getX();
    final float startingY = view.getY();
    return animate(view, new DecelerateInterpolator())
            .fadeIn()
            .translateBy(xOffset, yOffset)
            .onAnimationCancel(aView -> set(aView, startingX, startingY, OPAQUE))
            .schedule();
}
 
开发者ID:0ximDigital,项目名称:Rx2Animations,代码行数:10,代码来源:RxAnimations.java


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