Java Code Examples for android.view.View.getPaddingBottom()

The following are Jave code examples for showing how to use getPaddingBottom() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: popomusic   File: MyItemDecoration.java   Source Code and License Vote up 7 votes
public void drawHorizontal(Canvas c, RecyclerView parent) {

        final int childCount = parent.getChildCount();

        // 在每一个子控件的底部画线
        for (int i = 0; i < childCount; i++) {
            final View child = parent.getChildAt(i);

            final int left = child.getLeft() + child.getPaddingLeft();
            final int right = child.getWidth() + child.getLeft() - child.getPaddingRight();
            final int top = child.getBottom() - mDivider.getIntrinsicHeight() - child.getPaddingBottom();
            final int bottom = top + mDivider.getIntrinsicHeight();
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        }
    }
 
Example 2
Project: GitHub   File: SmartViewHolder.java   Source Code and License Vote up 6 votes
public SmartViewHolder(View itemView, AdapterView.OnItemClickListener mListener) {
    super(itemView);
    this.mListener = mListener;
    itemView.setOnClickListener(this);

    /**
     * 设置水波纹背景
     */
    if (itemView.getBackground() == null) {
        TypedValue typedValue = new TypedValue();
        Resources.Theme theme = itemView.getContext().getTheme();
        int top = itemView.getPaddingTop();
        int bottom = itemView.getPaddingBottom();
        int left = itemView.getPaddingLeft();
        int right = itemView.getPaddingRight();
        if (theme.resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true)) {
            itemView.setBackgroundResource(typedValue.resourceId);
        }
        itemView.setPadding(left, top, right, bottom);
    }
}
 
Example 3
Project: GitHub   File: DynamicHelper.java   Source Code and License Vote up 6 votes
/**
 * apply padding in view
 */
public static void applyPadding(View view, DynamicProperty property, int position) {
    if (view != null) {
        switch (property.type) {
            case DIMEN: {
                int[] padding = new int[] {
                  view.getPaddingLeft(),
                  view.getPaddingTop(),
                  view.getPaddingRight(),
                  view.getPaddingBottom()
                };
                padding[position] = property.getValueInt();
                view.setPadding(padding[0], padding[1], padding[2], padding[3]);
            }
            break;
        }
    }
}
 
Example 4
Project: DripUltraRefreshWithLoad   File: SmartViewHolder.java   Source Code and License Vote up 6 votes
public SmartViewHolder(View itemView, AdapterView.OnItemClickListener mListener) {
    super(itemView);

    /**
     * 设置水波纹背景
     */
    if (itemView.getBackground() == null) {
        TypedValue typedValue = new TypedValue();
        Resources.Theme theme = itemView.getContext().getTheme();
        int top = itemView.getPaddingTop();
        int bottom = itemView.getPaddingBottom();
        int left = itemView.getPaddingLeft();
        int right = itemView.getPaddingRight();
        if (theme.resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true)) {
            itemView.setBackgroundResource(typedValue.resourceId);
        }
        itemView.setPadding(left, top, right, bottom);
    }
}
 
Example 5
Project: richeditor   File: LuBottomMenu.java   Source Code and License Vote up 6 votes
private int getAllChildrenHeightSum(boolean withPadding, boolean withMargin) {
    final int childCount = getChildCount();
    int height = 0;
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        if (child.getVisibility() == GONE)
            continue;

        int margin = ((MarginLayoutParams) child.getLayoutParams()).topMargin +
                ((MarginLayoutParams) child.getLayoutParams()).bottomMargin;

        height += child.getMeasuredHeight() +
                (withPadding ? child.getPaddingTop() + child.getPaddingBottom() : 0) +
                (withMargin ? margin : 0);
    }
    return Math.max(height, 0);
}
 
Example 6
Project: AssistantBySDK   File: ChatListAdapter.java   Source Code and License Vote up 6 votes
/**
 * 获取指定区域item的高度
 **/
public int getItemsHeight(int start, int end) {
    int height = 0;
    if (start > end || end > datas.size() - 1) {
        return height;
    }
    start = start < 0 ? 0 : start;
    RecyclerView.LayoutManager layoutManager = mListFragment.getLayoutManager();
    for (int i = start; i <= end; i++) {
        View item = layoutManager.findViewByPosition(i);
        if (item != null) {
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) item.getLayoutParams();
            height += item.getHeight() + item.getPaddingBottom() + item.getPaddingTop() + layoutParams.topMargin + layoutParams.bottomMargin /*item.getBottom() - item.getTop()*/;
                /*int desiredWidth = View.MeasureSpec.makeMeasureSpec(item.getWidth(), View.MeasureSpec.AT_MOST);
                item.measure(desiredWidth, 0); // 计算子项View 的宽高
                height += item.getMeasuredHeight();*/
        }
    }

    return height;
}
 
Example 7
Project: exciting-app   File: AnimationBuilder.java   Source Code and License Vote up 5 votes
/**
 * @return the animation builder
 */
public AnimationBuilder standUp() {
    for (View view : views) {
        float x = (view.getWidth() - view.getPaddingLeft() - view.getPaddingRight()) / 2
                + view.getPaddingLeft();
        float y = view.getHeight() - view.getPaddingBottom();
        pivotX(x, x, x, x, x);
        pivotY(y, y, y, y, y);
        rotationX(55, -30, 15, -15, 0);
    }
    return this;
}
 
Example 8
Project: KUtils-master   File: WaveAnimator.java   Source Code and License Vote up 5 votes
@Override
public void prepare(View target) {
    float x = (target.getWidth() - target.getPaddingLeft() - target.getPaddingRight()) / 2
            + target.getPaddingLeft();
    float y = target.getHeight() - target.getPaddingBottom();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "rotation", 12, -12, 3, -3, 0),
            ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y)
    );
}
 
Example 9
Project: RLibrary   File: AnimationBuilder.java   Source Code and License Vote up 5 votes
/**
 * @return the animation builder
 */
public AnimationBuilder standUp() {
    for (View view : views) {
        float x = (view.getWidth() - view.getPaddingLeft() - view.getPaddingRight()) / 2
                + view.getPaddingLeft();
        float y = view.getHeight() - view.getPaddingBottom();
        pivotX(x, x, x, x, x);
        pivotY(y, y, y, y, y);
        rotationX(55, -30, 15, -15, 0);
    }
    return this;
}
 
Example 10
Project: LuaViewPlayground   File: RotateOutDownLeftAnimatorDecoration.java   Source Code and License Vote up 5 votes
@Override
protected void prepare(AnimatorSet animatorSet, View target) {
    float x = target.getPaddingLeft();
    float y = target.getHeight() - target.getPaddingBottom();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 0),
            ObjectAnimator.ofFloat(target, "rotation", 0, 90),
            ObjectAnimator.ofFloat(target, "pivotX", x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y)
    );
}
 
Example 11
Project: KUtils-master   File: RotateOutDownLeftAnimator.java   Source Code and License Vote up 5 votes
@Override
public void prepare(View target) {
    float x = target.getPaddingLeft();
    float y = target.getHeight() - target.getPaddingBottom();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 0),
            ObjectAnimator.ofFloat(target, "rotation", 0, 90),
            ObjectAnimator.ofFloat(target, "pivotX", x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y)
    );
}
 
Example 12
Project: KUtils   File: StandUpAnimator.java   Source Code and License Vote up 5 votes
@Override
public void prepare(View target) {
    float x = (target.getWidth() - target.getPaddingLeft() - target.getPaddingRight()) / 2
            + target.getPaddingLeft();
    float y = target.getHeight() - target.getPaddingBottom();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y),
            ObjectAnimator.ofFloat(target, "rotationX", 55, -30, 15, -15, 0)
    );
}
 
Example 13
Project: KUtils-master   File: RotateInUpRightAnimator.java   Source Code and License Vote up 5 votes
@Override
public void prepare(View target) {
    float x = target.getWidth() - target.getPaddingRight();
    float y = target.getHeight() - target.getPaddingBottom();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "rotation", -90, 0),
            ObjectAnimator.ofFloat(target, "alpha", 0, 1),
            ObjectAnimator.ofFloat(target, "pivotX", x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y)
    );
}
 
Example 14
Project: LuaViewPlayground   File: RotateInDownRightAnimatorDecoration.java   Source Code and License Vote up 5 votes
@Override
protected void prepare(AnimatorSet animatorSet, View target) {
    float x = target.getWidth() - target.getPaddingRight();
    float y = target.getHeight() - target.getPaddingBottom();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(target, "rotation", 90, 0),
            ObjectAnimator.ofFloat(target, "alpha", 0, 1),
            ObjectAnimator.ofFloat(target, "pivotX", x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y)
    );
}
 
Example 15
Project: LuaViewPlayground   File: RotateInDownLeftAnimatorDecoration.java   Source Code and License Vote up 5 votes
@Override
protected void prepare(AnimatorSet animatorSet, View target) {
    float x = target.getPaddingLeft();
    float y = target.getHeight() - target.getPaddingBottom();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(target, "rotation", -90, 0),
            ObjectAnimator.ofFloat(target, "alpha", 0, 1),
            ObjectAnimator.ofFloat(target, "pivotX", x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y)
    );
}
 
Example 16
Project: KUtils-master   File: RotateOutUpRightAnimator.java   Source Code and License Vote up 5 votes
@Override
public void prepare(View target) {
    float x = target.getWidth() - target.getPaddingRight();
    float y = target.getHeight() - target.getPaddingBottom();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 0),
            ObjectAnimator.ofFloat(target, "rotation", 0, 90),
            ObjectAnimator.ofFloat(target, "pivotX", x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y)
    );
}
 
Example 17
Project: SuperSelector   File: Util.java   Source Code and License Vote up 5 votes
public static void setItemStyle(View[] viewArray, int[] bgRes, boolean keepPadding) {
	List<View> layout = new ArrayList<View>();
	for (int i = 0; i < viewArray.length; i++) {
		View v = viewArray[i];
		if (v.getVisibility() == View.VISIBLE) {
			layout.add(v);
		}
	}
	for (int i = 0, count = layout.size(); i < count; i++) {
		View view = layout.get(i);
		int l = view.getPaddingLeft();
		int t = view.getPaddingTop();
		int r = view.getPaddingRight();
		int b = view.getPaddingBottom();
		if (count == 1) {
			view.setBackgroundResource(bgRes[0]);
		} else if (count >= 2 && i == 0) {
			view.setBackgroundResource(bgRes[1]);
		} else if (count >= 2 && i == (count - 1)) {
			view.setBackgroundResource(bgRes[3]);
		} else {
			view.setBackgroundResource(bgRes[2]);
		}
		if (keepPadding) {
			view.setPadding(l, t, r, b);
		}
	}
}
 
Example 18
Project: CommonFramework   File: DividerGridItemDecoration.java   Source Code and License Vote up 5 votes
public void drawHorizontal(Canvas c, RecyclerView parent) {
    int childCount = parent.getChildCount();

    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        int left = child.getLeft() - params.leftMargin;
        int right = child.getRight() + params.rightMargin + mDivider.getIntrinsicWidth();
        int top = child.getPaddingBottom() + params.bottomMargin;
        int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
Example 19
Project: KUtils-master   File: RotateInDownRightAnimator.java   Source Code and License Vote up 5 votes
@Override
public void prepare(View target) {
    float x = target.getWidth() - target.getPaddingRight();
    float y = target.getHeight() - target.getPaddingBottom();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "rotation", 90, 0),
            ObjectAnimator.ofFloat(target, "alpha", 0, 1),
            ObjectAnimator.ofFloat(target, "pivotX", x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y)
    );
}
 
Example 20
Project: BalaFM   File: FlowLayout.java   Source Code and License Vote up 4 votes
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    //确定此容器的宽高
    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    //测量子View的宽高
    int childCount = getChildCount();
    View child = null;
    //子view摆放的起始位置
    int left = getPaddingLeft();
    //一行view中将最大的高度存于此变量,用于子view进行换行时高度的计算
    int maxHeightInLine = 0;
    //存储所有行的高度相加,用于确定此容器的高度
    int allHeight = 0;
    for (int i = 0; i < childCount; i++) {
        child = getChildAt(i);
        //测量子View宽高
        measureChild(child, widthMeasureSpec, heightMeasureSpec);
        //两两对比,取得一行中最大的高度
        if (child.getMeasuredHeight() + child.getPaddingTop() + child.getPaddingBottom() > maxHeightInLine) {
            maxHeightInLine = child.getMeasuredHeight() + child.getPaddingTop() + child.getPaddingBottom();
        }
        left += child.getMeasuredWidth() + dip2px(horizontalSpace) + child.getPaddingLeft() + child.getPaddingRight();
        if (left >= widthSize - getPaddingRight() - getPaddingLeft()) {//换行
            left = getPaddingLeft();
            //累积行的总高度
            allHeight += maxHeightInLine + dip2px(verticalSpace);
            //因为换行了,所以每行的最大高度置0
            maxHeightInLine = 0;
        }
    }
    //再加上最后一行的高度,因为之前的高度累积条件是换行
    //最后一行没有换行操作,所以高度应该再加上
    allHeight += maxHeightInLine;

    if (widthMode != MeasureSpec.EXACTLY) {
        widthSize = mScreenWidth;//如果没有指定宽,则默认为屏幕宽
    }

    if (heightMode != MeasureSpec.EXACTLY) {//如果没有指定高度
        heightSize = allHeight + getPaddingBottom() + getPaddingTop();
    }

    setMeasuredDimension(widthSize, heightSize);
}