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

The following are Jave code examples for showing how to use getPaddingLeft() 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: simple-keyboard   File: MoreKeysKeyboardView.java   Source Code and License Vote up 7 votes
@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);
}
 
Example 2
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 3
Project: boohee_v5.6   File: AnimationBuilder.java   Source Code and License Vote up 6 votes
public AnimationBuilder standUp() {
    for (View view : this.views) {
        float x = (float) ((((view.getWidth() - view.getPaddingLeft()) - view.getPaddingRight
                ()) / 2) + view.getPaddingLeft());
        float y = (float) (view.getHeight() - view.getPaddingBottom());
        pivotX(x, x, x, x, x);
        pivotY(y, y, y, y, y);
        rotationX(55.0f, -30.0f, 15.0f, -15.0f, 0.0f);
    }
    return this;
}
 
Example 4
Project: GitHub   File: GridItemDecoration.java   Source Code and License Vote up 5 votes
/**
 * @param c
 * @param parent
 * @param state
 */
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (dividerDrawable == null) {
        return;
    }

    int childCount = parent.getChildCount();
    int rightV = parent.getWidth();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

        int leftV = parent.getPaddingLeft() + child.getPaddingLeft();
        int bottomV = child.getTop() - params.topMargin;
        int topV = bottomV - dividerDrawable.getIntrinsicHeight();

        int topH = child.getTop() + params.topMargin;
        int bottomH = child.getBottom() + params.bottomMargin;
        int rightH = child.getLeft() - params.leftMargin;
        int leftH = rightH - dividerDrawable.getIntrinsicWidth();
        dividerDrawable.setBounds(leftH, topH, rightH, bottomH);
        dividerDrawable.draw(c);
        dividerDrawable.setBounds(leftV, topV, rightV, bottomV);
        dividerDrawable.draw(c);
    }
}
 
Example 5
Project: silly-android   File: SillyAndroid.java   Source Code and License Vote up 5 votes
/**
 * Sets the top and bottom padding to the given View, keeping the horizontal padding values as the were.
 *
 * @param view    Which view to set the padding to, must not be {@code null}
 * @param padding The vertical padding value
 */
public static void setPaddingVertical(@NonNull final View view, @Px final int padding) {
    final int paddingStart = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? view.getPaddingStart() : view.getPaddingLeft();
    final int paddingEnd = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? view.getPaddingEnd() : view.getPaddingRight();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        view.setPaddingRelative(paddingStart, padding, paddingEnd, padding);
    } else {
        view.setPadding(paddingStart, padding, paddingEnd, padding);
    }
}
 
Example 6
Project: KUtils-master   File: RotateOutUpLeftAnimator.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 7
Project: guanggoo-android   File: MyHtmlHttpImageGetter.java   Source Code and License Vote up 5 votes
private float getScale(float originalDrawableWidth) {
    View container = containerReference.get();
    if (container == null) {
        return 1f;
    }

    float maxWidth = container.getWidth() - container.getPaddingLeft() - container.getPaddingRight();

    if (matchParentWidth) {
        return maxWidth / originalDrawableWidth;
    } else {
        return Math.min(maxWidth, originalDrawableWidth) / originalDrawableWidth;
    }
}
 
Example 8
Project: KUtils-master   File: HingeAnimator.java   Source Code and License Vote up 5 votes
@Override
public void prepare(View target) {
    float x = target.getPaddingLeft();
    float y = target.getPaddingTop();
    getAnimatorAgent().playTogether(
            Glider.glide(Skill.SineEaseInOut, 1300, ObjectAnimator.ofFloat(target, "rotation", 0, 80, 60, 80, 60, 60)),
            ObjectAnimator.ofFloat(target, "translationY", 0, 0, 0, 0, 0, 700),
            ObjectAnimator.ofFloat(target, "alpha", 1, 1, 1, 1, 1, 0),
            ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x, x),
            ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y, y)
    );

    setDuration(1300);
}
 
Example 9
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 10
Project: LuaViewPlayground   File: WaveAnimatorDecoration.java   Source Code and License Vote up 5 votes
@Override
protected void prepare(AnimatorSet animatorSet, View target) {
    float x = (target.getWidth() - target.getPaddingLeft() - target.getPaddingRight()) / 2
            + target.getPaddingLeft();
    float y = target.getHeight() - target.getPaddingBottom();
    animatorSet.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 11
Project: AOSP-Kayboard-7.1.2   File: KeyPreviewDrawParams.java   Source Code and License Vote up 5 votes
public void setGeometry(final View previewTextView) {
    final int previewWidth = previewTextView.getMeasuredWidth();
    final int previewHeight = mPreviewHeight;
    // The width and height of visible part of the key preview background. The content marker
    // of the background 9-patch have to cover the visible part of the background.
    mVisibleWidth = previewWidth - previewTextView.getPaddingLeft()
            - previewTextView.getPaddingRight();
    mVisibleHeight = previewHeight - previewTextView.getPaddingTop()
            - previewTextView.getPaddingBottom();
    // The distance between the top edge of the parent key and the bottom of the visible part
    // of the key preview background.
    setVisibleOffset(mPreviewOffset - previewTextView.getPaddingBottom());
}
 
Example 12
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 13
Project: KUtils   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 14
Project: chromium-for-android-56-debug-video   File: ViewUtils.java   Source Code and License Vote up 5 votes
/**
 * Sets the background of a view to the given 9-patch resource and restores its padding. This
 * works around a bug in Android where the padding is lost when a 9-patch resource is applied
 * programmatically.
 */
public static void setNinePatchBackgroundResource(View view, @DrawableRes int resource) {
    int left = view.getPaddingLeft();
    int top = view.getPaddingTop();
    int right = view.getPaddingRight();
    int bottom = view.getPaddingBottom();
    view.setBackgroundResource(resource);
    view.setPadding(left, top, right, bottom);
}
 
Example 15
Project: chromium-net-for-android   File: ApiCompatibilityUtils.java   Source Code and License Vote up 5 votes
/**
 * @see android.view.View#getPaddingStart()
 */
public static int getPaddingStart(View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return view.getPaddingStart();
    } else {
        // Before JB MR1, all layouts are left-to-right, so start == left.
        return view.getPaddingLeft();
    }
}
 
Example 16
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 17
Project: AOSP-Kayboard-7.1.2   File: MoreKeysKeyboardView.java   Source Code and License Vote up 5 votes
@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.getInstance().isAccessibilityEnabled()) {
        accessibilityDelegate.onShowMoreKeysKeyboard();
    }
}
 
Example 18
Project: dialog   File: FDialog.java   Source Code and License Vote up 5 votes
protected static void setBackgroundDrawable(View view, Drawable drawable)
{
    if (view == null)
    {
        return;
    }
    int paddingLeft = view.getPaddingLeft();
    int paddingTop = view.getPaddingTop();
    int paddingRight = view.getPaddingRight();
    int paddingBottom = view.getPaddingBottom();
    view.setBackgroundDrawable(drawable);
    view.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
}
 
Example 19
Project: KUtils   File: RotateInDownLeftAnimator.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, "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);
}