Java Code Examples for android.view.ViewGroup#getLeft()

The following examples show how to use android.view.ViewGroup#getLeft() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public boolean onDoubleTap(MotionEvent e) {
    if (mDoubleClickListener != null) {
        View target;
        ViewGroup bottom = getBottomView();
        ViewGroup surface = getSurfaceView();
        if (e.getX() > bottom.getLeft() && e.getX() < bottom.getRight()
                && e.getY() > bottom.getTop()
                && e.getY() < bottom.getBottom()) {
            target = bottom;
        } else {
            target = surface;
        }
        mDoubleClickListener.onDoubleClick(SwipeLayout.this,
                target == surface);
    }
    return true;
}
 
Example 2
/**
 * close surface
 *
 * @param smooth
 *            smoothly or not.
 * @param notify
 *            if notify all the listeners.
 */
public void close(boolean smooth, boolean notify) {
    ViewGroup surface = getSurfaceView();
    int dx, dy;
    if (smooth)
        mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(),
                getPaddingTop());
    else {
        Rect rect = computeSurfaceLayoutArea(false);
        dx = rect.left - surface.getLeft();
        dy = rect.top - surface.getTop();
        surface.layout(rect.left, rect.top, rect.right, rect.bottom);
        if (notify) {
            dispatchRevealEvent(rect.left, rect.top, rect.right,
                    rect.bottom);
            dispatchSwipeEvent(rect.left, rect.top, dx, dy);
        } else {
            safeBottomView();
        }
    }
    invalidate();
}
 
Example 3
@Override
public boolean onDoubleTap(MotionEvent e) {
    if (mDoubleClickListener != null) {
        View target;
        ViewGroup bottom = getBottomView();
        ViewGroup surface = getSurfaceView();
        if (e.getX() > bottom.getLeft() && e.getX() < bottom.getRight()
                && e.getY() > bottom.getTop()
                && e.getY() < bottom.getBottom()) {
            target = bottom;
        } else {
            target = surface;
        }
        mDoubleClickListener.onDoubleClick(SwipeLayoutConv.this,
                target == surface);
    }
    return true;
}
 
Example 4
/**
 * close surface
 *
 * @param smooth smoothly or not.
 * @param notify if notify all the listeners.
 */
public void close(boolean smooth, boolean notify) {
    ViewGroup surface = getSurfaceView();
    int dx, dy;
    if (smooth)
        mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(),
                getPaddingTop());
    else {
        Rect rect = computeSurfaceLayoutArea(false);
        dx = rect.left - surface.getLeft();
        dy = rect.top - surface.getTop();
        surface.layout(rect.left, rect.top, rect.right, rect.bottom);
        if (notify) {
            dispatchRevealEvent(rect.left, rect.top, rect.right,
                    rect.bottom);
            dispatchSwipeEvent(rect.left, rect.top, dx, dy);
        } else {
            safeBottomView();
        }
    }
    invalidate();
}
 
Example 5
Source Project: hintcase   File: HintCaseView.java    License: Apache License 2.0 6 votes vote down vote up
private void calculateHintBlockPosition(ViewGroup parent, Shape shape) {
    if (targetView == NO_TARGETVIEW) {
        hintBlockPosition = HintCase.HINT_BLOCK_POSITION_CENTER;
    } else {
        int[] areas = new int[4];
        areas[HintCase.HINT_BLOCK_POSITION_LEFT] = shape.getLeft() - parent.getLeft();
        areas[HintCase.HINT_BLOCK_POSITION_TOP] = shape.getTop() - parent.getTop();
        areas[HintCase.HINT_BLOCK_POSITION_RIGHT] = parent.getRight() - shape.getRight();
        areas[HintCase.HINT_BLOCK_POSITION_BOTTOM] = parent.getBottom() - shape.getBottom();
        hintBlockPosition = HintCase.HINT_BLOCK_POSITION_LEFT;
        for(int i = 1; i < areas.length; i++) {
            if(areas[i] >= areas[hintBlockPosition]) {
                hintBlockPosition = i;
            }
        }
    }
}
 
Example 6
/**
 * Aligns the shadow with {@param view}
 * @param viewParent immediate parent of {@param view}. It must be a sibling of this view.
 */
public void alignWithIconView(BubbleTextView view, ViewGroup viewParent) {
    float leftShift = view.getLeft() + viewParent.getLeft() - getLeft();
    float topShift = view.getTop() + viewParent.getTop() - getTop();
    int iconWidth = view.getRight() - view.getLeft();
    int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
    float drawableWidth = view.getIcon().getBounds().width();

    setTranslationX(leftShift
            + viewParent.getTranslationX()
            + view.getCompoundPaddingLeft() * view.getScaleX()
            + (iconHSpace - drawableWidth) * view.getScaleX() / 2  /* drawable gap */
            + iconWidth * (1 - view.getScaleX()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
    setTranslationY(topShift
            + viewParent.getTranslationY()
            + view.getPaddingTop() * view.getScaleY()  /* drawable gap */
            + view.getHeight() * (1 - view.getScaleY()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
}
 
Example 7
Source Project: QiQuYing   File: CategoryTabStrip.java    License: Apache License 2.0 6 votes vote down vote up
private void calculateIndicatorRect(Rect rect) {
	ViewGroup currentTab = (ViewGroup)tabsContainer.getChildAt(currentPosition);
	TextView category_text = (TextView) currentTab.findViewById(R.id.category_text);
	
	float left = (float) (currentTab.getLeft() + category_text.getLeft());
       float width = ((float) category_text.getWidth()) + left;
       
       if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
       	ViewGroup nextTab = (ViewGroup)tabsContainer.getChildAt(currentPosition + 1);
		TextView next_category_text = (TextView) nextTab.findViewById(R.id.category_text);
		
		float next_left = (float) (nextTab.getLeft() + next_category_text.getLeft());
		left = left * (1.0f - currentPositionOffset) + next_left * currentPositionOffset;
		width = width * (1.0f - currentPositionOffset) + currentPositionOffset * (((float) next_category_text.getWidth()) + next_left);
       }
       
       rect.set(((int) left) + getPaddingLeft(), getPaddingTop() + currentTab.getTop() + category_text.getTop(), 
			((int) width) + getPaddingLeft(), currentTab.getTop() + getPaddingTop() + category_text.getTop() + category_text.getHeight());

}
 
Example 8
Source Project: AutoLoadListView   File: ZSwipeItem.java    License: Apache License 2.0 6 votes vote down vote up
public void close(boolean smooth, boolean notify) {
	ViewGroup surface = getSurfaceView();
	int dx, dy;
	if (smooth)
		mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(),
				getPaddingTop());
	else {
		Rect rect = computeSurfaceLayoutArea(false);
		dx = rect.left - surface.getLeft();
		dy = rect.top - surface.getTop();
		surface.layout(rect.left, rect.top, rect.right, rect.bottom);
		if (notify) {
			dispatchSwipeEvent(rect.left, rect.top, dx, dy);
		} else {
			safeBottomView();
		}
	}
	invalidate();
}
 
Example 9
Source Project: ZListVIew   File: ZSwipeItem.java    License: Apache License 2.0 6 votes vote down vote up
public void close(boolean smooth, boolean notify) {
	ViewGroup surface = getSurfaceView();
	int dx, dy;
	if (smooth)
		mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(),
				getPaddingTop());
	else {
		Rect rect = computeSurfaceLayoutArea(false);
		dx = rect.left - surface.getLeft();
		dy = rect.top - surface.getTop();
		surface.layout(rect.left, rect.top, rect.right, rect.bottom);
		if (notify) {
			dispatchSwipeEvent(rect.left, rect.top, dx, dy);
		} else {
			safeBottomView();
		}
	}
	invalidate();
}
 
Example 10
Source Project: UltimateAndroid   File: SwipeLayout.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean onDoubleTap(MotionEvent e) {
    if(mDoubleClickListener != null){
        View target;
        ViewGroup bottom = getBottomView();
        ViewGroup surface = getSurfaceView();
        if(e.getX() > bottom.getLeft() && e.getX() < bottom.getRight()
                && e.getY() > bottom.getTop() && e.getY() < bottom.getBottom()){
            target = bottom;
        }else{
            target = surface;
        }
        mDoubleClickListener.onDoubleClick(SwipeLayout.this, target == surface);
    }
    return true;
}
 
Example 11
Source Project: UltimateAndroid   File: SwipeLayout.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * close surface
 * @param smooth smoothly or not.
 * @param notify if notify all the listeners.
 */
public void close(boolean smooth, boolean notify){
    ViewGroup surface = getSurfaceView();
    int dx, dy;
    if(smooth)
        mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(), getPaddingTop());
    else {
        Rect rect = computeSurfaceLayoutArea(false);
        dx = rect.left - surface.getLeft();
        dy = rect.top - surface.getTop();
        surface.layout(rect.left, rect.top, rect.right, rect.bottom);
        if(notify) {
            dispatchRevealEvent(rect.left, rect.top, rect.right, rect.bottom);
            dispatchSwipeEvent(rect.left, rect.top, dx, dy);
        }else{
            safeBottomView();
        }
    }
    invalidate();
}
 
Example 12
Source Project: android-animations   File: Zoom.java    License: MIT License 5 votes vote down vote up
public static AnimatorSet OutRight(View view){
    AnimatorSet animatorSet = new AnimatorSet();
    ViewGroup parent = (ViewGroup) view.getParent();
    int distance = parent.getWidth() - parent.getLeft();

    ObjectAnimator object1 = ObjectAnimator.ofFloat(view,    "alpha", 1, 1, 0);
    ObjectAnimator object2 = ObjectAnimator.ofFloat(view,    "scaleX", 1, 0.475f, 0.1f);
    ObjectAnimator object3 = ObjectAnimator.ofFloat(view, "scaleY", 1, 0.475f, 0.1f);
    ObjectAnimator object4 = ObjectAnimator.ofFloat(view,     "translationX", 0, -42, distance);

    animatorSet.playTogether(object1, object2, object3, object4);
    return animatorSet;
}
 
Example 13
/**
 * Aligns the shadow with {@param view}
 * @param viewParent immediate parent of {@param view}. It must be a sibling of this view.
 */
public void alignWithIconView(BubbleTextView view, ViewGroup viewParent, View clipAgainstView) {
    float leftShift = view.getLeft() + viewParent.getLeft() - getLeft();
    float topShift = view.getTop() + viewParent.getTop() - getTop();
    int iconWidth = view.getRight() - view.getLeft();
    int iconHeight = view.getBottom() - view.getTop();
    int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
    float drawableWidth = view.getIcon().getBounds().width();

    if (clipAgainstView != null) {
        // Set the bounds to clip against
        int[] coords = new int[] {0, 0};
        Utilities.getDescendantCoordRelativeToAncestor(clipAgainstView, (View) getParent(),
                coords, false);
        int clipLeft = (int) Math.max(0, coords[0] - leftShift - mShadowPadding);
        int clipTop = (int) Math.max(0, coords[1] - topShift - mShadowPadding) ;
        setClipBounds(new Rect(clipLeft, clipTop, clipLeft + iconWidth, clipTop + iconHeight));
    } else {
        // Reset the clip bounds
        setClipBounds(null);
    }

    setTranslationX(leftShift
            + viewParent.getTranslationX()
            + view.getCompoundPaddingLeft() * view.getScaleX()
            + (iconHSpace - drawableWidth) * view.getScaleX() / 2  /* drawable gap */
            + iconWidth * (1 - view.getScaleX()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
    setTranslationY(topShift
            + viewParent.getTranslationY()
            + view.getPaddingTop() * view.getScaleY()  /* drawable gap */
            + view.getHeight() * (1 - view.getScaleY()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
}
 
Example 14
Source Project: KUtils   File: ZoomOutRightAnimator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void prepare(View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getWidth() - parent.getLeft();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 1, 0),
            ObjectAnimator.ofFloat(target, "scaleX", 1, 0.475f, 0.1f),
            ObjectAnimator.ofFloat(target, "scaleY", 1, 0.475f, 0.1f),
            ObjectAnimator.ofFloat(target, "translationX", 0, -42, distance)
    );
}
 
Example 15
@Override
protected void prepare(View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getWidth() - parent.getLeft();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 1, 0),
            ObjectAnimator.ofFloat(target, "scaleX", 1, 0.475f, 0.1f),
            ObjectAnimator.ofFloat(target, "scaleY", 1, 0.475f, 0.1f),
            ObjectAnimator.ofFloat(target, "translationX", 0, -42, distance)
    );
}
 
Example 16
@Override
public ItemPictureGridHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View itemView = LayoutInflater.from(activity).inflate(R.layout.item_picture_grid, parent, false);
    int itemViewWidth = (parent.getRight() - parent.getLeft()) / PictureGridActivity.RECYCLER_VIEW_COLUMN;
    //设置宽高 使其为正方形
    itemView.setLayoutParams(new RecyclerView.LayoutParams(itemViewWidth, itemViewWidth));
    return new ItemPictureGridHolder(itemView);
}
 
Example 17
Source Project: PicturePicker   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public SampleHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ImageView imageView = new ImageView(MainActivity.this);
    int w = (parent.getRight() - parent.getLeft()) / 3;
    imageView.setLayoutParams(new LinearLayout.LayoutParams(w, w));
    imageView.setPadding(1, 1, 1, 1);
    return new SampleHolder(imageView);
}
 
Example 18
Source Project: QiQuYing   File: CategoryTabStrip.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void draw(Canvas canvas) {
	super.draw(canvas);
	
       calculateIndicatorRect(indicatorRect);
       
	if(indicator != null) {
		indicator.setBounds(indicatorRect);
		indicator.draw(canvas);
	}
	
       int i = 0;
       while (i < tabsContainer.getChildCount()) {
           if (i < currentPosition - 1 || i > currentPosition + 1) {
               i++;
           } else {
           	ViewGroup tab = (ViewGroup)tabsContainer.getChildAt(i);
           	TextView category_text = (TextView) tab.findViewById(R.id.category_text);
               if (category_text != null) {
                   TextDrawable textDrawable = drawables[i - currentPosition + 1];
                   int save = canvas.save();
                   calculateIndicatorRect(indicatorRect);
                   canvas.clipRect(indicatorRect);
                   textDrawable.setText(category_text.getText());
                   textDrawable.setTextSize(0, category_text.getTextSize());
                   textDrawable.setTextColor(getResources().getColor(R.color.main_color));
                   int left = tab.getLeft() + category_text.getLeft() + (category_text.getWidth() - textDrawable.getIntrinsicWidth()) / 2 + getPaddingLeft();
                   int top = tab.getTop() + category_text.getTop() + (category_text.getHeight() - textDrawable.getIntrinsicHeight()) / 2 + getPaddingTop();
                   textDrawable.setBounds(left, top, textDrawable.getIntrinsicWidth() + left, textDrawable.getIntrinsicHeight() + top);
                   textDrawable.draw(canvas);
                   canvas.restoreToCount(save);
               }
               i++;
           }
       }
       
}
 
Example 19
@Override
protected void prepare(View target) {
    ViewGroup parent = (ViewGroup)target.getParent();
    int distance = parent.getWidth() - parent.getLeft();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target,"alpha", 1, 1, 0),
            ObjectAnimator.ofFloat(target,"scaleX",1,0.475f,0.1f),
            ObjectAnimator.ofFloat(target,"scaleY",1,0.475f,0.1f),
            ObjectAnimator.ofFloat(target,"translationX",0,-42,distance)
    );
}
 
Example 20
@Override
protected void prepare(View target) {
    ViewGroup parent = (ViewGroup)target.getParent();
    int distance = parent.getWidth() - parent.getLeft();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target,"alpha", 1, 1, 0),
            ObjectAnimator.ofFloat(target,"scaleX",1,0.475f,0.1f),
            ObjectAnimator.ofFloat(target,"scaleY",1,0.475f,0.1f),
            ObjectAnimator.ofFloat(target,"translationX",0,-42,distance)
    );
}