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

The following examples show how to use android.view.ViewGroup#getLeft() . 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
Source File: SwipeLayout.java    From o2oa with GNU Affero General Public License v3.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 2
Source File: SwipeLayout.java    From o2oa with GNU Affero General Public License v3.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 3
Source File: SwipeLayoutConv.java    From o2oa with GNU Affero General Public License v3.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(SwipeLayoutConv.this,
                target == surface);
    }
    return true;
}
 
Example 4
Source File: SwipeLayoutConv.java    From o2oa with GNU Affero General Public License v3.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 5
Source File: SwipeLayout.java    From UltimateAndroid with 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 6
Source File: HintCaseView.java    From hintcase with 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 7
Source File: SwipeLayout.java    From UltimateAndroid with 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 8
Source File: ZSwipeItem.java    From ZListVIew with 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 File: ClickShadowView.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 10
Source File: CategoryTabStrip.java    From QiQuYing with 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 11
Source File: ZSwipeItem.java    From AutoLoadListView with 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 12
Source File: MainActivity.java    From PicturePicker with 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 13
Source File: ZoomOutRightAnimator.java    From UltimateAndroid with 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 14
Source File: ZoomOutRightAnimator.java    From UltimateAndroid with 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
Source File: CategoryTabStrip.java    From QiQuYing with 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 16
Source File: Zoom.java    From android-animations with 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 17
Source File: PictureGridAdapter.java    From PicturePicker with Apache License 2.0 5 votes vote down vote up
@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 18
Source File: ZoomOutRightAnimator.java    From KUtils-master with 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 19
Source File: ZoomOutRightAnimator.java    From KUtils with 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 20
Source File: ClickShadowView.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 */
            );
}