List of usage examples for android.view View getLeft
@ViewDebug.CapturedViewProperty public final int getLeft()
From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dx Delta scrolled in pixels// ww w . j ava 2 s . c om * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.android.tv.menu.MenuLayoutManager.java
private void dumpChildren(String prefix) { int position = 0; for (MenuRowView view : mMenuRowViews) { View title = view.getChildAt(0); View contents = view.getChildAt(1); Log.d(TAG, prefix + " position=" + position++ + " rowView={visiblility=" + view.getVisibility() + ", alpha=" + view.getAlpha() + ", translationY=" + view.getTranslationY() + ", left=" + view.getLeft() + ", top=" + view.getTop() + ", right=" + view.getRight() + ", bottom=" + view.getBottom() + "}, title={visiblility=" + title.getVisibility() + ", alpha=" + title.getAlpha() + ", translationY=" + title.getTranslationY() + ", left=" + title.getLeft() + ", top=" + title.getTop() + ", right=" + title.getRight() + ", bottom=" + title.getBottom() + "}, contents={visiblility=" + contents.getVisibility() + ", alpha=" + contents.getAlpha() + ", translationY=" + contents.getTranslationY() + ", left=" + contents.getLeft() + ", top=" + contents.getTop() + ", right=" + contents.getRight() + ", bottom=" + contents.getBottom() + "}"); }//from w w w .ja v a 2 s. c o m }
From source file:com.android.hcframe.DraggableGridViewPager.java
private void animateDragged() { if (mLastDragged >= 0) { final View v = getChildAt(mLastDragged); final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); r.inset(-r.width() / 20, -r.height() / 20); v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY)); v.layout(r.left, r.top, r.right, r.bottom); AnimationSet animSet = new AnimationSet(true); ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2); scale.setDuration(ANIMATION_DURATION); AlphaAnimation alpha = new AlphaAnimation(1, .5f); alpha.setDuration(ANIMATION_DURATION); animSet.addAnimation(scale);//from w w w . j a va2 s . co m animSet.addAnimation(alpha); animSet.setFillEnabled(true); animSet.setFillAfter(true); v.clearAnimation(); v.startAnimation(animSet); } }
From source file:com.pitchedapps.primenumbercalculator.Calculator.java
License:asdf
private void reveal(View sourceView, AnimatorListener listener) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay(); final Rect displayRect = new Rect(); mDisplayView.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(this); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(themeClearAccent); groupOverlay.add(revealView);// w w w.j av a2 s . c o m final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); alphaAnimator.addListener(listener); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); mCurrentAnimator = null; } }); mCurrentAnimator = animatorSet; animatorSet.start(); }
From source file:com.chauthai.swipereveallayout.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dx Delta scrolled in pixels along the X axis * @param dy Delta scrolled in pixels along the Y axis * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. *//*from w ww.j av a 2 s .c o m*/ protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }
From source file:com.ab.view.sliding.AbSlidingTabView2.java
/** * //from w w w .java 2 s . co m * ??? * @param index * @throws */ public void computeTabImg(int index) { for (int i = 0; i < tabItemList.size(); i++) { TextView tv = tabItemList.get(i); tv.setTextColor(tabColor); tv.setSelected(false); if (index == i) { tv.setTextColor(tabSelectColor); tv.setSelected(true); } } // final View tabView = mTabLayout.getChildAt(index); AbViewUtil.measureView(tabView); LayoutParams mParams = new LayoutParams(tabView.getMeasuredWidth(), tabSlidingHeight); mParams.topMargin = -tabSlidingHeight; mTabImg.setLayoutParams(mParams); if (D) Log.d(TAG, "old--startX:" + startX); //????????tab if (D) Log.d(TAG, "view" + index + ":" + tabView.getMeasuredWidth()); if (D) Log.d(TAG, "ScrollView:" + mTabScrollView.getWidth()); if (D) Log.d(TAG, "scrollX:" + scrollX); if (D) Log.d(TAG, "tabView right:" + tabView.getRight()); if (D) Log.d(TAG, "tabView left:" + tabView.getLeft()); if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) { if (D) Log.d(TAG, "??"); int offsetX = 0; //?? if (index == mTabLayout.getChildCount() - 1) { offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; if (D) Log.d(TAG, "startX:" + startX + ",offsetX:" + offsetX); imageSlide(mTabImg, startX, mTabScrollView.getWidth() - tabView.getMeasuredWidth(), 0, 0); startX = mTabScrollView.getWidth() - tabView.getMeasuredWidth(); } else { offsetX = tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; if (D) Log.d(TAG, "startX:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) { if (D) Log.d(TAG, "?"); //? offsetX int offsetX = 0; if (index == 0) { offsetX = -scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; imageSlide(mTabImg, startX, 0, 0, 0); startX = 0; } else { offsetX = -tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; if (D) Log.d(TAG, "startX2:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else { int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } mSelectedTabIndex = index; }
From source file:co.codecrunch.musicplayerlite.slidinguppanelhelper.SlidingUpPanelLayout.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v/* ww w .j av a 2s . co m*/ * View to test for horizontal scrollability * @param checkV * Whether the view v passed should itself be checked for * scrollability (true), or just its children (false). * @param dx * Delta scrolled in pixels * @param x * X coordinate of the active touch point * @param y * Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance // first. for (int i = count - 1; i >= 0; i--) { final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.android.widget.SlidingPaneLayout.java
@Override public void draw(Canvas c) { super.draw(c); final View shadowView = getChildCount() > 1 ? getChildAt(1) : null; if (shadowView == null || mShadowDrawable == null) { // No need to draw a shadow if we don't have one. return;/* ww w . j a v a2 s. c o m*/ } final int shadowHeight = mShadowDrawable.getIntrinsicHeight(); final int right = shadowView.getRight(); final int left = shadowView.getLeft(); final int bottom = shadowView.getTop(); final int top = bottom - shadowHeight; mShadowDrawable.setBounds(left, top, right, bottom); mShadowDrawable.draw(c); }
From source file:com.cyanogenmod.filemanager.ui.widgets.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dx Delta scrolled in pixels along the X axis * @param dy Delta scrolled in pixels along the Y axis * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. *//*from w w w . ja va 2 s. c o m*/ protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && (v.canScrollHorizontally(-dx) || v.canScrollVertically(-dy)); }
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothTabView.java
/** * ???./*from ww w . ja v a 2 s.c o m*/ * * @param index the index */ public void computeTabImg(int index) { for (int i = 0; i < tabItemList.size(); i++) { TextView tv = tabItemList.get(i); tv.setTextColor(tabColor); tv.setSelected(false); if (index == i) { tv.setTextColor(tabSelectColor); tv.setSelected(true); } } // final View tabView = mTabLayout.getChildAt(index); AbViewUtil.measureView(tabView); LayoutParams mParams = new LayoutParams(tabView.getMeasuredWidth(), tabSlidingHeight); mParams.topMargin = -tabSlidingHeight; mTabImg.setLayoutParams(mParams); AbLogUtil.d(AbSlidingSmoothTabView.class, "old--startX:" + startX); //????????tab AbLogUtil.d(AbSlidingSmoothTabView.class, "view" + index + ":" + tabView.getMeasuredWidth()); AbLogUtil.d(AbSlidingSmoothTabView.class, "ScrollView:" + mTabScrollView.getWidth()); AbLogUtil.d(AbSlidingSmoothTabView.class, "scrollX:" + scrollX); AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView right:" + tabView.getRight()); AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView left:" + tabView.getLeft()); if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) { AbLogUtil.d(AbSlidingSmoothTabView.class, "??"); int offsetX = 0; //?? if (index == mTabLayout.getChildCount() - 1) { offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX); imageSlide(mTabImg, startX, mTabScrollView.getWidth() - tabView.getMeasuredWidth(), 0, 0); startX = mTabScrollView.getWidth() - tabView.getMeasuredWidth(); } else { offsetX = tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) { AbLogUtil.d(AbSlidingSmoothTabView.class, "?"); //? offsetX int offsetX = 0; if (index == 0) { offsetX = -scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; imageSlide(mTabImg, startX, 0, 0, 0); startX = 0; } else { offsetX = -tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; AbLogUtil.d(AbSlidingSmoothTabView.class, "startX2:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else { int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } mSelectedTabIndex = index; }