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

The following examples show how to use android.view.View#getPaddingBottom() . 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: KeyboardUtils.java    From tysq-android with GNU General Public License v3.0 6 votes vote down vote up
/**
     * Fix the bug of 5497 in Android.
     * <p>Don't set adjustResize</p>
     *
     * @param activity The activity.
     */
    public static void fixAndroidBug5497(final Activity activity) {
//        Window window = activity.getWindow();
//        int softInputMode = window.getAttributes().softInputMode;
//        window.setSoftInputMode(softInputMode & ~WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        final FrameLayout contentView = activity.findViewById(android.R.id.content);
        final View contentViewChild = contentView.getChildAt(0);
        final int paddingBottom = contentViewChild.getPaddingBottom();
        sContentViewInvisibleHeightPre5497 = getContentViewInvisibleHeight(activity);
        contentView.getViewTreeObserver()
                .addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        int height = getContentViewInvisibleHeight(activity);
                        if (sContentViewInvisibleHeightPre5497 != height) {
                            contentViewChild.setPadding(
                                    contentViewChild.getPaddingLeft(),
                                    contentViewChild.getPaddingTop(),
                                    contentViewChild.getPaddingRight(),
                                    paddingBottom + getDecorViewInvisibleHeight(activity)
                            );
                            sContentViewInvisibleHeightPre5497 = height;
                        }
                    }
                });
    }
 
Example 2
Source File: DynamicHelper.java    From json2view with MIT License 6 votes vote down vote up
/**
 * 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 3
Source File: SmartViewHolder.java    From SmartRefreshHorizontal with Apache License 2.0 6 votes vote down vote up
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 4
Source File: AutoUtils.java    From AutoLayout with Apache License 2.0 6 votes vote down vote up
public static void autoPadding(View view)
{
    Object tag = view.getTag(R.id.id_tag_autolayout_padding);
    if (tag != null) return;
    view.setTag(R.id.id_tag_autolayout_padding, "Just Identify");

    int l = view.getPaddingLeft();
    int t = view.getPaddingTop();
    int r = view.getPaddingRight();
    int b = view.getPaddingBottom();

    l = getPercentWidthSize(l);
    t = getPercentHeightSize(t);
    r = getPercentWidthSize(r);
    b = getPercentHeightSize(b);

    view.setPadding(l, t, r, b);
}
 
Example 5
Source File: RotateInDownRightAnimator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: PaddingTopAttr.java    From AutoLayout with Apache License 2.0 5 votes vote down vote up
@Override
protected void execute(View view, int val)
{
    int l = view.getPaddingLeft();
    int t = val;
    int r = view.getPaddingRight();
    int b = view.getPaddingBottom();
    view.setPadding(l, t, r, b);

}
 
Example 7
Source File: StickerSetGroupInfoCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), heightMeasureSpec);
    if (isLast) {
        View parent = (View) getParent();
        if (parent != null) {
            int height = parent.getMeasuredHeight() - parent.getPaddingBottom() - parent.getPaddingTop() - AndroidUtilities.dp(24);
            if (getMeasuredHeight() < height) {
                setMeasuredDimension(getMeasuredWidth(), height);
            }
        }
    }
}
 
Example 8
Source File: RotateInUpRightAnimator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: MoreKeysKeyboardView.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void showMoreKeysPanel(final View parentView, final Controller controller,
        final int pointX, final int pointY, final KeyboardActionListener listener) {
    mController = controller;
    mListener = listener;
    final View container = getContainerView();
    // The coordinates of panel's left-top corner in parentView's coordinate system.
    // We need to consider background drawable paddings.
    final int x = pointX - getDefaultCoordX() - container.getPaddingLeft() - getPaddingLeft();
    final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom()
            + getPaddingBottom();

    parentView.getLocationInWindow(mCoordinates);
    // Ensure the horizontal position of the panel does not extend past the parentView edges.
    final int maxX = parentView.getMeasuredWidth() - container.getMeasuredWidth();
    final int panelX = Math.max(0, Math.min(maxX, x)) + CoordinateUtils.x(mCoordinates);
    final int panelY = y + CoordinateUtils.y(mCoordinates);
    container.setX(panelX);
    container.setY(panelY);

    mOriginX = x + container.getPaddingLeft();
    mOriginY = y + container.getPaddingTop();
    controller.onShowMoreKeysPanel(this);
    final MoreKeysKeyboardAccessibilityDelegate accessibilityDelegate = mAccessibilityDelegate;
    if (accessibilityDelegate != null
            && AccessibilityUtils.Companion.getInstance().isAccessibilityEnabled()) {
        accessibilityDelegate.onShowMoreKeysKeyboard();
    }
}
 
Example 10
Source File: RotateInUpLeftAnimator.java    From KUtils with Apache License 2.0 5 votes vote down vote up
@Override
public void prepare(View target) {
    float x = target.getPaddingLeft();
    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 11
Source File: PaddingLeftAttr.java    From AutoLayout-Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void execute(View view, int val) {
    int l = val;
    int t = view.getPaddingTop();
    int r = view.getPaddingRight();
    int b = view.getPaddingBottom();
    view.setPadding(l, t, r, b);

}
 
Example 12
Source File: RotateInDownLeftAnimator.java    From KUtils with Apache License 2.0 5 votes vote down vote up
@Override
public void prepare(View target) {
    float x = target.getPaddingLeft();
    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 13
Source File: RotateOutUpLeftAnimator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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 14
Source File: PaddingRightAttr.java    From AutoLayout-Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void execute(View view, int val) {
    int l = view.getPaddingLeft();
    int t = view.getPaddingTop();
    int r = val;
    int b = view.getPaddingBottom();
    view.setPadding(l, t, r, b);

}
 
Example 15
Source File: OField.java    From framework with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initLayout() {
    removeAllViews();
    if (useTemplate) {
        View layout = LayoutInflater.from(mContext).inflate(
                R.layout.base_control_template, this, false);

        if (withPadding) {
            int top_padding = layout.getPaddingTop();
            int right_padding = layout.getPaddingRight();
            int bottom_padding = layout.getPaddingBottom();
            int left_padding = layout.getPaddingLeft();
            if (!with_bottom_padding) {
                layout.setPadding(left_padding, top_padding, right_padding, 0);
            }
            if (!with_top_padding) {
                layout.setPadding(left_padding, 0, right_padding, bottom_padding);
            }
        } else {
            layout.setPadding(0, 0, 0, 0);
        }
        addView(layout);
        container = (ViewGroup) findViewById(R.id.control_container);
        img_icon = (ImageView) findViewById(android.R.id.icon);
        img_icon.setColorFilter(tint_color);
        setImageIcon();
    } else {
        container = this;
    }
}
 
Example 16
Source File: Rotate.java    From android-animations with MIT License 5 votes vote down vote up
public static AnimatorSet InUpRight(View view){
    AnimatorSet animatorSet = new AnimatorSet();
    float x = view.getWidth() - view.getPaddingRight();
    float y = view.getHeight() - view.getPaddingBottom();

    ObjectAnimator object1 =   ObjectAnimator.ofFloat(view, "rotation", -90, 0);
    ObjectAnimator object2 =   ObjectAnimator.ofFloat(view, "alpha", 0, 1);
    ObjectAnimator object3 =   ObjectAnimator.ofFloat(view, "pivotX", x, x);
    ObjectAnimator object4 =   ObjectAnimator.ofFloat(view, "pivotY", y, y);

    animatorSet.playTogether(object1, object2, object3, object4);
    return animatorSet;
}
 
Example 17
Source File: PaddingRightAttr.java    From AndroidAutoLayout with Apache License 2.0 5 votes vote down vote up
@Override
protected void execute(View view, int val)
{
    int l = view.getPaddingLeft();
    int t = view.getPaddingTop();
    int r = val;
    int b = view.getPaddingBottom();
    view.setPadding(l, t, r, b);

}
 
Example 18
Source File: MeasureSpecDelegater.java    From libcommon with Apache License 2.0 4 votes vote down vote up
public static MeasureSpec onMeasure(@NonNull final View target,
		final double requestedAspect,
		@IScaledView.ScaleMode final int scaleMode,
		final boolean needResizeToKeepAspect,
		final int widthMeasureSpec, final int heightMeasureSpec) {

		final MeasureSpec result = new MeasureSpec(widthMeasureSpec, heightMeasureSpec);
//		if (DEBUG) Log.v(TAG, "onMeasure:requestedAspect=" + requestedAspect);
// 		要求されたアスペクト比が負の時(初期生成時)は何もしない
		if ((requestedAspect > 0)
			&& (scaleMode == SCALE_MODE_KEEP_ASPECT)
			&& needResizeToKeepAspect) {

			int initialWidth = View.MeasureSpec.getSize(widthMeasureSpec);
			int initialHeight = View.MeasureSpec.getSize(heightMeasureSpec);
			final int horizPadding = target.getPaddingLeft() + target.getPaddingRight();
			final int vertPadding = target.getPaddingTop() + target.getPaddingBottom();
			initialWidth -= horizPadding;
			initialHeight -= vertPadding;

			final double viewAspectRatio = (double)initialWidth / initialHeight;
			final double aspectDiff = requestedAspect / viewAspectRatio - 1;

			// 計算誤差が生じる可能性が有るので指定した値との差が小さければそのままにする
			if (Math.abs(aspectDiff) > 0.005) {
				if (aspectDiff > 0) {
					// 幅基準で高さを決める
					initialHeight = (int) (initialWidth / requestedAspect);
				} else {
					// 高さ基準で幅を決める
					initialWidth = (int) (initialHeight * requestedAspect);
				}
				initialWidth += horizPadding;
				initialHeight += vertPadding;
				result.widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(initialWidth, View.MeasureSpec.EXACTLY);
				result.heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(initialHeight, View.MeasureSpec.EXACTLY);
			}
		}

		return result;
	}
 
Example 19
Source File: ItemAlignment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * get alignment position relative to optical left/top of itemView.
 */
public int getAlignmentPosition(View itemView) {
    LayoutParams p = (LayoutParams) itemView.getLayoutParams();
    View view = itemView;
    if (mViewId != 0) {
        view = itemView.findViewById(mViewId);
        if (view == null) {
            view = itemView;
        }
    }
    int alignPos;
    if (mOrientation == HORIZONTAL) {
        if (mOffset >= 0) {
            alignPos = mOffset;
            if (mOffsetWithPadding) {
                alignPos += view.getPaddingLeft();
            }
        } else {
            alignPos = view == itemView ? p.getOpticalWidth(view) : view.getWidth()
                    + mOffset;
            if (mOffsetWithPadding) {
                alignPos -= view.getPaddingRight();
            }
        }
        if (mOffsetPercent != ITEM_ALIGN_OFFSET_PERCENT_DISABLED) {
            alignPos += ((view == itemView ? p.getOpticalWidth(view) : view.getWidth())
                    * mOffsetPercent) / 100f;
        }
        if (itemView != view) {
            mRect.left = alignPos;
            ((ViewGroup) itemView).offsetDescendantRectToMyCoords(view, mRect);
            alignPos = mRect.left - p.getOpticalLeftInset();
        }
    } else {
        if (mOffset >= 0) {
            alignPos = mOffset;
            if (mOffsetWithPadding) {
                alignPos += view.getPaddingTop();
            }
        } else {
            alignPos = view == itemView ? p.getOpticalHeight(view) : view.getHeight()
                    + mOffset;
            if (mOffsetWithPadding) {
                alignPos += view.getPaddingBottom();
            }
        }
        if (mOffsetPercent != ITEM_ALIGN_OFFSET_PERCENT_DISABLED) {
            alignPos += ((view == itemView ? p.getOpticalHeight(view) : view.getHeight())
                    * mOffsetPercent) / 100f;
        }
        if (itemView != view) {
            mRect.top = alignPos;
            ((ViewGroup) itemView).offsetDescendantRectToMyCoords(view, mRect);
            alignPos = mRect.top - p.getOpticalTopInset();
        }
    }
    return alignPos;
}
 
Example 20
Source File: SettingSelectorView.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public void loadData() {
    tvSettingName.setText(selector.getSettingName());
    if (selector.getCurrentOptionIndex() >= 0 && selector.getCurrentOptionIndex() < selector
            .getOptionCount()) {
        tvCurrentOption.setText(selector.getOptionName(selector.getCurrentOptionIndex()));
    } else {
        tvCurrentOption.setText("");
    }
    llOptions.removeAllViews();
    if (selector != null) {
        int count = selector.getOptionCount();
        for (int i = 0;
             i < count;
             i++) {
            View v = inflater.inflate(R.layout.list_item_setting_option, null);
            llOptions.addView(v, LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT);
            TextView tv = (TextView) v.findViewById(R.id.tv_option_name);
            TextView tvNote = (TextView) v.findViewById(R.id.tv_option_note);
            ImageView iv = (ImageView) v.findViewById(R.id.iv_check);
            tv.setText(selector.getOptionName(i));
            CharSequence note = selector.getOptionNote(i);
            if (note == null || note.length() == 0) {
                tvNote.setText("");
            } else {
                tvNote.setText(note);
            }
            tvNote.setCompoundDrawablesWithIntrinsicBounds(null, null,
                    selector.getOptionDrawable(i), null);
            if (i == selector.getCurrentOptionIndex()) {
                iv.setVisibility(View.VISIBLE);
            } else {
                iv.setVisibility(View.GONE);
            }
            v.setOnClickListener(new OptionClick(i));
            if (i == count - 1) {
                preOptionBottomSpace = v.getPaddingBottom();
                v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(),
                        preOptionBottomSpace + bottomSpace);
            }
        }
    }
}