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


Java View.getLeft方法代码示例

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


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

示例1: calcOffset

import android.view.View; //导入方法依赖的package包/类
private void calcOffset() {
        final View currentTabView = mTabsContainer.getChildAt(this.mCurrentTab);
        mCurrentP.left = currentTabView.getLeft();
        mCurrentP.right = currentTabView.getRight();

        final View lastTabView = mTabsContainer.getChildAt(this.mLastTab);
        mLastP.left = lastTabView.getLeft();
        mLastP.right = lastTabView.getRight();

//        Log.d("AAA", "mLastP--->" + mLastP.left + "&" + mLastP.right);
//        Log.d("AAA", "mCurrentP--->" + mCurrentP.left + "&" + mCurrentP.right);
        if (mLastP.left == mCurrentP.left && mLastP.right == mCurrentP.right) {
            invalidate();
        } else {
            mValueAnimator.setObjectValues(mLastP, mCurrentP);
            if (mIndicatorBounceEnable) {
                mValueAnimator.setInterpolator(mInterpolator);
            }

            if (mIndicatorAnimDuration < 0) {
                mIndicatorAnimDuration = mIndicatorBounceEnable ? 500 : 250;
            }
            mValueAnimator.setDuration(mIndicatorAnimDuration);
            mValueAnimator.start();
        }
    }
 
开发者ID:Kelvin65535,项目名称:Android_Songshuhui,代码行数:27,代码来源:SegmentTabLayout.java

示例2: drawShadow

import android.view.View; //导入方法依赖的package包/类
public void drawShadow(View content, Canvas canvas) {
	if (mShadowDrawable == null || mShadowWidth <= 0) return;
	int left = 0;
	if (mMode == SlidingMenu.LEFT) {
		left = content.getLeft() - mShadowWidth;
	} else if (mMode == SlidingMenu.RIGHT) {
		left = content.getRight();
	} else if (mMode == SlidingMenu.LEFT_RIGHT) {
		if (mSecondaryShadowDrawable != null) {
			left = content.getRight();
			mSecondaryShadowDrawable.setBounds(left, 0, left + mShadowWidth, getHeight());
			mSecondaryShadowDrawable.draw(canvas);
		}
		left = content.getLeft() - mShadowWidth;
	}
	mShadowDrawable.setBounds(left, 0, left + mShadowWidth, getHeight());
	mShadowDrawable.draw(canvas);
}
 
开发者ID:QuixomTech,项目名称:WeatherStream,代码行数:19,代码来源:CustomViewBehind.java

示例3: onDrawOver

import android.view.View; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    final int count = parent.getChildCount();

    for (int layoutPos = 0; layoutPos < count; layoutPos++) {
        final View child = parent.getChildAt(layoutPos);

        final int adapterPos = parent.getChildAdapterPosition(child);

        if (adapterPos != RecyclerView.NO_POSITION && (layoutPos == 0 || hasHeader(adapterPos))) {
            View header = getHeader(parent, adapterPos).itemView;
            c.save();
            final int left = child.getLeft();
            final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos);
            c.translate(left, top);
            header.setTranslationX(left);
            header.setTranslationY(top);
            header.draw(c);
            c.restore();
        }
    }
}
 
开发者ID:yedashen,项目名称:UltimateRecyclerView,代码行数:26,代码来源:StickyHeaderDecoration.java

示例4: draw

import android.view.View; //导入方法依赖的package包/类
public void draw(Canvas c) {
    Drawable shadowDrawable;
    super.draw(c);
    if (isLayoutRtlSupport()) {
        shadowDrawable = this.mShadowDrawableRight;
    } else {
        shadowDrawable = this.mShadowDrawableLeft;
    }
    View shadowView = getChildCount() > 1 ? getChildAt(1) : null;
    if (shadowView != null && shadowDrawable != null) {
        int left;
        int right;
        int top = shadowView.getTop();
        int bottom = shadowView.getBottom();
        int shadowWidth = shadowDrawable.getIntrinsicWidth();
        if (isLayoutRtlSupport()) {
            left = shadowView.getRight();
            right = left + shadowWidth;
        } else {
            right = shadowView.getLeft();
            left = right - shadowWidth;
        }
        shadowDrawable.setBounds(left, top, right, bottom);
        shadowDrawable.draw(c);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:SlidingPaneLayout.java

示例5: scrollToChild

import android.view.View; //导入方法依赖的package包/类
private void scrollToChild(int position, int offset) {

        if (tabCount == 0) {
            return;
        }

        // lee.sz {
        View v = tabsContainer.getChildAt(position);
        int newScrollX = v.getLeft() + offset;

        if (position > 0 || offset > 0) {
            scrollOffset = (getWidth() / 2) - (v.getWidth() / 2);
            newScrollX -= scrollOffset;
        }
        // lee.sz }

        if (newScrollX != lastScrollX) {
            lastScrollX = newScrollX;
            scrollTo(newScrollX, 0);
        }

    }
 
开发者ID:teisun,项目名称:SunmiUI,代码行数:23,代码来源:PagerSlidingTabStrip.java

示例6: canScroll

import android.view.View; //导入方法依赖的package包/类
/**
 * Tests scroll ability within child views of v given a delta of dx.
 *
 * @param v      View to test for horizontal scroll ability
 * @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--) {
            // 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, x + scrollX - child.getLeft(),
                            y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}
 
开发者ID:DSM-DMS,项目名称:DMS,代码行数:33,代码来源:CalendarView.java

示例7: checkIfBubbleIsOverTrash

import android.view.View; //导入方法依赖的package包/类
private boolean checkIfBubbleIsOverTrash(BubbleLayout bubble) {
    boolean result = false;
    if (trashView.getVisibility() == View.VISIBLE) {
        View trashContentView = getTrashContent();
        int trashWidth = trashContentView.getMeasuredWidth();
        int trashHeight = trashContentView.getMeasuredHeight();
        int trashLeft = (trashContentView.getLeft() - (trashWidth / 2));
        int trashRight = (trashContentView.getLeft() + trashWidth + (trashWidth / 2));
        int trashTop = (trashContentView.getTop() - (trashHeight / 2));
        int trashBottom = (trashContentView.getTop() + trashHeight + (trashHeight / 2));
        int bubbleWidth = bubble.getMeasuredWidth();
        int bubbleHeight = bubble.getMeasuredHeight();
        int bubbleLeft = bubble.getViewParams().x;
        int bubbleRight = bubbleLeft + bubbleWidth;
        int bubbleTop = bubble.getViewParams().y;
        int bubbleBottom = bubbleTop + bubbleHeight;
        if (bubbleLeft >= trashLeft && bubbleRight <= trashRight) {
            if (bubbleTop >= trashTop && bubbleBottom <= trashBottom) {
                result = true;
            }
        }
    }
    return result;
}
 
开发者ID:isacan,项目名称:Andzu,代码行数:25,代码来源:BubblesLayoutCoordinator.java

示例8: canScroll

import android.view.View; //导入方法依赖的package包/类
/**
 * 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
 * @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);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:31,代码来源:SlidingUpPanelLayout.java

示例9: getEnd

import android.view.View; //导入方法依赖的package包/类
static int getEnd(View v, boolean withoutPadding) {
  if (v == null) {
    return 0;
  }
  if (isLayoutRtl(v)) {
    return (withoutPadding) ? v.getLeft() + getPaddingEnd(v) : v.getLeft();
  } else {
    return (withoutPadding) ? v.getRight() - getPaddingEnd(v) : v.getRight();
  }
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:11,代码来源:Utils.java

示例10: getAbsLeftBound

import android.view.View; //导入方法依赖的package包/类
public int getAbsLeftBound(View content) {
	if (mMode == SlidingMenu.LEFT || mMode == SlidingMenu.LEFT_RIGHT) {
		return content.getLeft() - getBehindWidth();
	} else if (mMode == SlidingMenu.RIGHT) {
		return content.getLeft();
	}
	return 0;
}
 
开发者ID:6ag,项目名称:LiuAGeAndroid,代码行数:9,代码来源:CustomViewBehind.java

示例11: setPressedItem

import android.view.View; //导入方法依赖的package包/类
private void setPressedItem(View child, int position, float x, float y) {
    this.mDrawsInPressedState = true;
    if (VERSION.SDK_INT >= 21) {
        drawableHotspotChanged(x, y);
    }
    if (!isPressed()) {
        setPressed(true);
    }
    layoutChildren();
    if (this.mMotionPosition != -1) {
        View motionView = getChildAt(this.mMotionPosition - getFirstVisiblePosition());
        if (!(motionView == null || motionView == child || !motionView.isPressed())) {
            motionView.setPressed(false);
        }
    }
    this.mMotionPosition = position;
    float childX = x - ((float) child.getLeft());
    float childY = y - ((float) child.getTop());
    if (VERSION.SDK_INT >= 21) {
        child.drawableHotspotChanged(childX, childY);
    }
    if (!child.isPressed()) {
        child.setPressed(true);
    }
    positionSelectorLikeTouchCompat(position, child, x, y);
    setSelectorEnabled(false);
    refreshDrawableState();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:ListPopupWindow.java

示例12: getRelativeLeft

import android.view.View; //导入方法依赖的package包/类
private int getRelativeLeft(View myView) {
    if (myView.getParent() == myView.getRootView())
        return myView.getLeft();
    else
        return myView.getLeft() + getRelativeLeft((View) myView.getParent());
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:7,代码来源:BrowseNearbyActivity.java

示例13: calcIndicatorRect

import android.view.View; //导入方法依赖的package包/类
private void calcIndicatorRect() {
    View currentTabView = mTabsContainer.getChildAt(this.mCurrentTab);
    float left = currentTabView.getLeft();
    float right = currentTabView.getRight();

    //for mIndicatorWidthEqualTitle
    if (mIndicatorStyle == STYLE_NORMAL && mIndicatorWidthEqualTitle) {
        TextView tab_title = (TextView) currentTabView.findViewById(R.id.tv_tab_title);
        mTextPaint.setTextSize(mTextsize);
        float textWidth = mTextPaint.measureText(tab_title.getText().toString());
        margin = (right - left - textWidth) / 2;
    }

    if (this.mCurrentTab < mTabCount - 1) {
        View nextTabView = mTabsContainer.getChildAt(this.mCurrentTab + 1);
        float nextTabLeft = nextTabView.getLeft();
        float nextTabRight = nextTabView.getRight();

        left = left + mCurrentPositionOffset * (nextTabLeft - left);
        right = right + mCurrentPositionOffset * (nextTabRight - right);

        //for mIndicatorWidthEqualTitle
        if (mIndicatorStyle == STYLE_NORMAL && mIndicatorWidthEqualTitle) {
            TextView next_tab_title = (TextView) nextTabView.findViewById(R.id.tv_tab_title);
            mTextPaint.setTextSize(mTextsize);
            float nextTextWidth = mTextPaint.measureText(next_tab_title.getText().toString());
            float nextMargin = (nextTabRight - nextTabLeft - nextTextWidth) / 2;
            margin = margin + mCurrentPositionOffset * (nextMargin - margin);
        }
    }

    mIndicatorRect.left = (int) left;
    mIndicatorRect.right = (int) right;
    //for mIndicatorWidthEqualTitle
    if (mIndicatorStyle == STYLE_NORMAL && mIndicatorWidthEqualTitle) {
        mIndicatorRect.left = (int) (left + margin - 1);
        mIndicatorRect.right = (int) (right - margin - 1);
    }

    mTabRect.left = (int) left;
    mTabRect.right = (int) right;

    if (mIndicatorWidth < 0) {   //indicatorWidth小于0时,原jpardogo's PagerSlidingTabStrip

    } else {//indicatorWidth大于0时,圆角矩形以及三角形
        float indicatorLeft = currentTabView.getLeft() + (currentTabView.getWidth() - mIndicatorWidth) / 2;

        if (this.mCurrentTab < mTabCount - 1) {
            View nextTab = mTabsContainer.getChildAt(this.mCurrentTab + 1);
            indicatorLeft = indicatorLeft + mCurrentPositionOffset * (currentTabView.getWidth() / 2 + nextTab.getWidth() / 2);
        }

        mIndicatorRect.left = (int) indicatorLeft;
        mIndicatorRect.right = (int) (mIndicatorRect.left + mIndicatorWidth);
    }
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:57,代码来源:SlidingTabLayout.java

示例14: onDraw

import android.view.View; //导入方法依赖的package包/类
@Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        View view = getChildAt(0);
        float width = view.getWidth();
        float height = view.getHeight();
        int left1 = view.getLeft();
        int top1 = view.getTop();
        float w = left1+width / 2;
        float h = top1+height / 2;
        float x = left1 +view.getTranslationX()+ width / 2;
        float y = top1 +view.getTranslationY()+ height / 2;
        path.reset();


        //移动点
        canvas.drawCircle(x, y, RADIUS_MOVE, paint);


        double sqrt = Math.sqrt((x - w) * (x - w) + (y - h) * (y - h));


        if (sqrt >= DISTANCE || isLeave) {
            doLeave();
            return;
        }
        float p = (float) ((OUTLENGTH - sqrt) / OUTLENGTH);


        float radius = ORGINLENGTH * p;
        canvas.drawCircle(w, h, radius, paint);
//        Log.i(TAG, "draw: " + sqrt);
        double cose = (x - w) / sqrt;
        double sine = (y - h) / sqrt;


        double dy = RADIUS_MOVE * cose;
        double dx = RADIUS_MOVE * sine;
        double dy1 = radius * cose;
        double dx1 = radius * sine;


        float x1 = (float) (w - dx1);
        float y1 = (float) (h + dy1);

        float x4 = (float) (w + dx1);
        float y4 = (float) (h - dy1);


        float x2 = (float) (x - dx);
        float y2 = (float) (y + dy);

        float x3 = (float) (x + dx);
        float y3 = (float) (y - dy);


        float xx = w + (x - w) / 2;
        float yy = h + (y - h) / 2;

        path.moveTo(x1, y1);
        path.quadTo(xx, yy, x2, y2);

        path.lineTo(x3, y3);
        path.quadTo(xx, yy, x4, y4);
        path.close();

        canvas.drawPath(path, paint);

//        canvas.drawCircle(x1, y1, 15, paint1);
//        canvas.drawCircle(x2, y2, 15, paint1);
//        canvas.drawCircle(x3, y3, 15, paint2);
//        canvas.drawCircle(x4, y4, 15, paint2);
//        canvas.drawCircle(xx, yy, 15, paint2);
    }
 
开发者ID:pop1234o,项目名称:BestPracticeApp,代码行数:75,代码来源:PointLayout.java

示例15: onInterceptTouchEvent

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
    debugLog("onInterceptTouchEvent");

    //if (e.getAction() == MotionEvent.ACTION_DOWN)
    {
        View itemView = rv.findChildViewUnder(e.getX(), e.getY());

        if (itemView == null)
            return false;

        boolean dragging = false;

        if ((dragHandleWidth > 0) && (e.getX() < dragHandleWidth)) {
            dragging = true;
        } else if (viewHandleId != -1) {
            //Find the handle in the list item
            View handleView = itemView.findViewById(viewHandleId);

            if (handleView == null) {
                Log.e(TAG, "The view ID " + viewHandleId + " was not found in the RecycleView item");
                return false;
            }

            //View should be visible to drag
            if (handleView.getVisibility() != View.VISIBLE) {
                return false;
            }

            //We need to find the relative position of the handle to the parent view
            //Then we can work out if the touch is within the handle
            int[] parentItemPos = new int[2];
            itemView.getLocationInWindow(parentItemPos);

            int[] handlePos = new int[2];
            handleView.getLocationInWindow(handlePos);

            int xRel = handlePos[0] - parentItemPos[0];
            int yRel = handlePos[1] - parentItemPos[1];

            Rect touchBounds = new Rect(itemView.getLeft() + xRel, itemView.getTop() + yRel,
                    itemView.getLeft() + xRel + handleView.getWidth(),
                    itemView.getTop() + yRel + handleView.getHeight()
            );

            if (touchBounds.contains((int) e.getX(), (int) e.getY()))
                dragging = true;

            debugLog("parentItemPos = " + parentItemPos[0] + " " + parentItemPos[1]);
            debugLog("handlePos = " + handlePos[0] + " " + handlePos[1]);
        }


        if (dragging) {
            debugLog("Started Drag");

            setIsDragging(true);

            floatingItem = createFloatingBitmap(itemView);

            fingerAnchorY = (int) e.getY();
            fingerOffsetInViewY = fingerAnchorY - itemView.getTop();
            fingerY = fingerAnchorY;

            selectedDragItemPos = rv.getChildLayoutPosition(itemView);
            debugLog("selectedDragItemPos = " + selectedDragItemPos);

            return true;
        }
    }
    return false;
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:73,代码来源:DragSortRecycler.java


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