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

The following are Jave code examples for showing how to use getPaddingRight() 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: MetadataEditor   File: GeneralUtils.java   Source Code and License Vote up 6 votes
public static void setBackgroundDrawable(View v, Drawable drawable) {
    if (v != null) {
        int paddingLeft = v.getPaddingLeft();
        int paddingTop = v.getPaddingTop();
        int paddingRight = v.getPaddingRight();
        int paddingBottom = v.getPaddingBottom();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
            v.setBackgroundDrawable(drawable);
        else
            v.setBackground(drawable);

        v.setPadding(paddingLeft,
                paddingTop,
                paddingRight,
                paddingBottom);
    }
}
 
Example 2
Project: popomusic   File: MyItemDecoration.java   Source Code and License Vote up 6 votes
public void drawVertical(Canvas c, RecyclerView parent) {

        final int childCount = parent.getChildCount();

        // 在每一个子控件的右侧画线
        for (int i = 0; i < childCount; i++) {
            final View child = parent.getChildAt(i);
            int right = child.getRight() - child.getPaddingRight();
            int left = right - mDivider.getIntrinsicWidth();
            final int top = child.getTop() + child.getPaddingTop();
            final int bottom = child.getTop() + child.getHeight() - child.getPaddingBottom();

            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        }
    }
 
Example 3
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 4
Project: WaitView   File: WaitViewController.java   Source Code and License Vote up 6 votes
public static WaitViewController from(View view) {
    if (view instanceof WaitView) {
        return ((WaitView) view).getController();
    }

    int width = view.getWidth();
    int height = view.getHeight();
    if (width == 0) {
        int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        view.measure(spec, spec);
        width = view.getMeasuredWidth();
        height = view.getMeasuredHeight();
    }

    RectF drawRect = new RectF(0, 0, width-view.getPaddingLeft()-view.getPaddingRight(), height-view.getPaddingTop()-view.getPaddingBottom());
    WaitViewController controller = (WaitViewController) view.getTag(R.id.ta_waitview);
    if (controller == null) {
        controller = new WaitViewController(view, drawRect);
        view.setTag(R.id.ta_waitview, controller);
    }
    return controller;
}
 
Example 5
Project: SmartRefreshLayout   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 6
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 7
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 8
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 9
Project: wallpaperboard   File: ViewHelper.java   Source Code and License Vote up 5 votes
public static void resetViewBottomPadding(@Nullable View view, boolean scroll) {
    if (view == null) return;

    Context context = ContextHelper.getBaseContext(view);
    int orientation = context.getResources().getConfiguration().orientation;

    int left = view.getPaddingLeft();
    int right = view.getPaddingRight();
    int bottom = view.getPaddingTop();
    int top = view.getPaddingTop();
    int navBar = 0;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        boolean tabletMode = context.getResources().getBoolean(R.bool.android_helpers_tablet_mode);
        if (tabletMode || orientation == Configuration.ORIENTATION_PORTRAIT) {
            navBar = getNavigationBarHeight(context);
        }

        if (!scroll) {
            navBar += getStatusBarHeight(context);
        }
    }

    if (!scroll) {
        navBar += getToolbarHeight(context);
    }
    view.setPadding(left, top, right, (bottom + navBar));
}
 
Example 10
Project: XERUNG   File: VerifyOTP.java   Source Code and License Vote up 5 votes
@Override
public boolean onTouch(final View v, final MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN && drawable != null) {
        final int x = (int) event.getX();
        final int y = (int) event.getY();
        final Rect bounds = drawable.getBounds();
        if (x >= (v.getRight() - bounds.width() - fuzz) && x <= (v.getRight() - v.getPaddingRight() + fuzz)
                && y >= (v.getPaddingTop() - fuzz) && y <= (v.getHeight() - v.getPaddingBottom()) + fuzz) {
            return onDrawableTouch(event);
        }
    }
    return false;
}
 
Example 11
Project: NeoTerm   File: PhoneArithmetics.java   Source Code and License Vote up 5 votes
@Override
public final int getPadding(@NonNull final Axis axis, final int gravity,
                            @NonNull final View view) {
    ensureNotNull(axis, "The axis may not be null");
    ensureTrue(gravity == Gravity.START || gravity == Gravity.END, "Invalid gravity");
    ensureNotNull(view, "The view may not be null");

    if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) {
        return gravity == Gravity.START ? view.getPaddingTop() : view.getPaddingBottom();
    } else {
        return gravity == Gravity.START ? view.getPaddingLeft() : view.getPaddingRight();
    }
}
 
Example 12
Project: LuaViewPlayground   File: StandUpAnimatorDecoration.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, "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: LuaViewPlayground   File: RotateInUpRightAnimatorDecoration.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 14
Project: chromium-for-android-56-debug-video   File: ChromeSwitchPreference.java   Source Code and License Vote up 5 votes
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    if (mDrawDivider) {
        int left = view.getPaddingLeft();
        int right = view.getPaddingRight();
        int top = view.getPaddingTop();
        int bottom = view.getPaddingBottom();
        view.setBackground(DividerDrawable.create(getContext()));
        view.setPadding(left, top, right, bottom);
    }

    SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.switch_widget);
    // On BLU Life Play devices SwitchPreference.setWidgetLayoutResource() does nothing. As a
    // result, the user will see a non-material Switch and switchView will be null, hence the
    // null check below. http://crbug.com/451447
    if (switchView != null) {
        switchView.setChecked(isChecked());
    }

    TextView title = (TextView) view.findViewById(android.R.id.title);
    title.setSingleLine(false);
    if (!mDontUseSummaryAsTitle && TextUtils.isEmpty(getTitle())) {
        TextView summary = (TextView) view.findViewById(android.R.id.summary);
        title.setText(summary.getText());
        title.setVisibility(View.VISIBLE);
        summary.setVisibility(View.GONE);
    }

    if (mManagedPrefDelegate != null) mManagedPrefDelegate.onBindViewToPreference(this, view);
}
 
Example 15
Project: KUtils-master   File: RotateOutDownRightAnimator.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 16
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 17
Project: KUtils   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 18
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);
}
 
Example 19
Project: SmartChart   File: Utils.java   Source Code and License Vote up 4 votes
static int getPaddingHorizontally(View v) {
  if (v == null) {
    return 0;
  }
  return v.getPaddingLeft() + v.getPaddingRight();
}
 
Example 20
Project: boohee_v5.6   File: ViewCompat.java   Source Code and License Vote up 4 votes
public int getPaddingEnd(View view) {
    return view.getPaddingRight();
}