android.view.View#getPaddingLeft ( )源码实例Demo

下面列出了android.view.View#getPaddingLeft ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ViewInspector   文件: DrawUtil.java
public static void drawPadding(View view, Canvas canvas) {
  int width = view.getWidth();
  int height = view.getHeight();
  int lPad = view.getPaddingLeft();
  int tPad = view.getPaddingTop();
  int rPad = view.getPaddingRight();
  int bPad = view.getPaddingBottom();

  Rect lRect = new Rect(0, 0, lPad, height);
  Rect tRect = new Rect(lPad, 0, width - rPad, tPad);
  Rect rRect = new Rect(width - rPad, 0, width, height);
  Rect bRect = new Rect(lPad, height - bPad, width - rPad, height);
  Paint paint = new Paint();
  paint.setColor(PADDING_COLOR);
  canvas.drawRect(lRect, paint);
  canvas.drawRect(tRect, paint);
  canvas.drawRect(rRect, paint);
  canvas.drawRect(bRect, paint);
}
 
源代码2 项目: ShineButton   文件: ShineView.java
public void showAnimation(ShineButton shineButton) {
    btnWidth = shineButton.getWidth();
    btnHeight = shineButton.getHeight();
    thirdLength = getThirdLength(btnHeight, btnWidth);
    int[] location = new int[2];
    shineButton.getLocationInWindow(location);
    centerAnimX = location[0] + shineButton.getWidth() / 2;
    centerAnimY = location[1] + shineButton.getHeight() / 2;

    if ( shineButton.mFixDialog != null && shineButton.mFixDialog.getWindow() != null ) {
        View decor = shineButton.mFixDialog.getWindow().getDecorView();
        centerAnimX = centerAnimX - decor.getPaddingLeft();
        centerAnimY = centerAnimY - decor.getPaddingTop();
    }

    shineAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            value = (float) valueAnimator.getAnimatedValue();
            if (shineSize != 0 && shineSize > 0) {
                paint.setStrokeWidth((shineSize) * (shineDistanceMultiple - value));
                paintSmall.setStrokeWidth(((float) shineSize / 3 * 2) * (shineDistanceMultiple - value));
            } else {
                paint.setStrokeWidth((btnWidth / 2) * (shineDistanceMultiple - value));
                paintSmall.setStrokeWidth((btnWidth / 3) * (shineDistanceMultiple - value));
            }
            rectF.set(centerAnimX - (btnWidth / (3 - shineDistanceMultiple) * value), centerAnimY - (btnHeight / (3 - shineDistanceMultiple) * value), centerAnimX + (btnWidth / (3 - shineDistanceMultiple) * value), centerAnimY + (btnHeight / (3 - shineDistanceMultiple) * value));
            rectFSmall.set(centerAnimX - (btnWidth / ((3 - shineDistanceMultiple) + distanceOffset) * value), centerAnimY - (btnHeight / ((3 - shineDistanceMultiple) + distanceOffset) * value), centerAnimX + (btnWidth / ((3 - shineDistanceMultiple) + distanceOffset) * value), centerAnimY + (btnHeight / ((3 - shineDistanceMultiple) + distanceOffset) * value));
            invalidate();
        }
    });
    shineAnimator.startAnim();
    clickAnimator.start();
}
 
源代码3 项目: wallpaperboard   文件: ViewHelper.java
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));
}
 
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());
}
 
源代码5 项目: UltimateAndroid   文件: RotateInUpLeftAnimator.java
@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)
    );
}
 
源代码6 项目: 365browser   文件: ApiCompatibilityUtils.java
/**
 * @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();
    }
}
 
源代码7 项目: UltimateAndroid   文件: RotateOutUpLeftAnimator.java
@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)
    );
}
 
源代码8 项目: openboard   文件: KeyPreviewDrawParams.java
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());
}
 
源代码9 项目: AndroidCommons   文件: Views.java
public static void setBackgroundKeepPadding(@NonNull View view, @Nullable Drawable drawable) {
    final Rect padding = new Rect(
            view.getPaddingLeft(), view.getPaddingTop(),
            view.getPaddingRight(), view.getPaddingBottom());

    setBackground(view, drawable);

    view.setPadding(padding.left, padding.top, padding.right, padding.bottom);
}
 
源代码10 项目: KUtils-master   文件: WaveAnimator.java
@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)
    );
}
 
源代码11 项目: PlayTogether   文件: PaddingBottomAttr.java
@Override
protected void execute(View view, int val)
{
    int l = view.getPaddingLeft();
    int t = view.getPaddingTop();
    int r = view.getPaddingRight();
    int b = val;
    view.setPadding(l, t, r, b);

}
 
源代码12 项目: FairEmail   文件: DrawerLayoutEx.java
@Override
public boolean dispatchGenericMotionEvent(MotionEvent ev) {
    if (isLocked()) {
        View content = getChildAt(0);
        Rect rect = new Rect();
        content.getHitRect(rect);
        rect.left += content.getPaddingLeft();
        rect.right -= content.getPaddingRight();
        if (rect.contains((int) ev.getX(), (int) ev.getY()))
            return content.dispatchGenericMotionEvent(ev);
    }

    return super.dispatchGenericMotionEvent(ev);
}
 
源代码13 项目: UltimateAndroid   文件: HingeAnimator.java
@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);
}
 
源代码14 项目: delion   文件: ChromeSwitchPreference.java
@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);
}
 
源代码15 项目: androidtestdebug   文件: FitCenterFrameLayout.java
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    final int childCount = getChildCount();

    final int parentLeft = getPaddingLeft();
    final int parentTop = getPaddingTop();
    final int parentRight = r - l - getPaddingRight();
    final int parentBottom = b - t - getPaddingBottom();

    final int parentWidth = parentRight - parentLeft;
    final int parentHeight = parentBottom - parentTop;

    int unpaddedWidth, unpaddedHeight, parentUnpaddedWidth, parentUnpaddedHeight;
    int childPaddingLeft, childPaddingTop, childPaddingRight, childPaddingBottom;

    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == GONE) {
            continue;
        }

        // Fit and center the child within the parent. Make sure not to consider padding
        // as part of the child's aspect ratio.

        childPaddingLeft = child.getPaddingLeft();
        childPaddingTop = child.getPaddingTop();
        childPaddingRight = child.getPaddingRight();
        childPaddingBottom = child.getPaddingBottom();

        unpaddedWidth = child.getMeasuredWidth() - childPaddingLeft - childPaddingRight;
        unpaddedHeight = child.getMeasuredHeight() - childPaddingTop - childPaddingBottom;

        parentUnpaddedWidth = parentWidth - childPaddingLeft - childPaddingRight;
        parentUnpaddedHeight = parentHeight - childPaddingTop - childPaddingBottom;

        if (parentUnpaddedWidth * unpaddedHeight > parentUnpaddedHeight * unpaddedWidth) {
            // The child view should be left/right letterboxed.
            final int scaledChildWidth = unpaddedWidth * parentUnpaddedHeight
                    / unpaddedHeight + childPaddingLeft + childPaddingRight;
            child.layout(
                    parentLeft + (parentWidth - scaledChildWidth) / 2,
                    parentTop,
                    parentRight - (parentWidth - scaledChildWidth) / 2,
                    parentBottom);
        } else {
            // The child view should be top/bottom letterboxed.
            final int scaledChildHeight = unpaddedHeight * parentUnpaddedWidth
                    / unpaddedWidth + childPaddingTop + childPaddingBottom;
            child.layout(
                    parentLeft,
                    parentTop + (parentHeight - scaledChildHeight) / 2,
                    parentRight,
                    parentTop + (parentHeight + scaledChildHeight) / 2);
        }
    }
}
 
源代码16 项目: android-chromium   文件: InfoBarLayout.java
/**
 * Update the backgrounds for the buttons to account for their current positioning.
 * The primary and secondary buttons are special-cased in that their backgrounds change to
 * create the illusion of a single-stroke boundary between them.
 */
private void updateBackgroundsForButtons() {
    boolean bothButtonsExist = findViewById(R.id.button_primary) != null
            && findViewById(R.id.button_secondary) != null;

    for (int row = 0; row < mIndicesOfRows.size() - 1; row++) {
        final int rowStart = mIndicesOfRows.get(row);
        final int rowEnd = mIndicesOfRows.get(row + 1);
        final int rowSize = rowEnd - rowStart;

        for (int i = rowStart; i < rowEnd; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() == View.GONE || !isButton(child)) continue;

            // Determine which background we need to show.
            int background;
            if (row == 0) {
                // Button will be floating.
                background = mBackgroundFloating;
            } else if (rowSize == 1 || !bothButtonsExist) {
                // Button takes up the full width of the screen.
                background = mBackgroundFullRight;
            } else if (mLayoutRTL) {
                // Primary button will be to the left of the secondary.
                background = child.getId() == R.id.button_primary
                        ? mBackgroundFullLeft : mBackgroundFullRight;
            } else {
                // Primary button will be to the right of the secondary.
                background = child.getId() == R.id.button_primary
                        ? mBackgroundFullRight : mBackgroundFullLeft;
            }

            // Update the background.
            LayoutParams params = (LayoutParams) child.getLayoutParams();
            if (params.background != background) {
                params.background = background;

                // Save the padding; Android decides to overwrite it on some builds.
                int paddingLeft = child.getPaddingLeft();
                int paddingTop = child.getPaddingTop();
                int paddingRight = child.getPaddingRight();
                int paddingBottom = child.getPaddingBottom();
                int buttonWidth = child.getMeasuredWidth();
                int buttonHeight = child.getMeasuredHeight();

                // Set the background, then restore the padding.
                child.setBackgroundResource(background);
                child.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);

                // Re-measuring is necessary to correct the text gravity.
                int specWidth = MeasureSpec.makeMeasureSpec(buttonWidth, MeasureSpec.EXACTLY);
                int specHeight = MeasureSpec.makeMeasureSpec(buttonHeight, MeasureSpec.EXACTLY);
                measureChild(child, specWidth, specHeight);
            }
        }
    }
}
 
源代码17 项目: KUtils-master   文件: Utils.java
static int getPaddingHorizontally(View v) {
  if (v == null) {
    return 0;
  }
  return v.getPaddingLeft() + v.getPaddingRight();
}
 
源代码18 项目: SmartTabLayout   文件: Utils.java
static int getPaddingHorizontally(View v) {
  if (v == null) {
    return 0;
  }
  return v.getPaddingLeft() + v.getPaddingRight();
}
 
源代码19 项目: Camera2   文件: TopRightWeightedLayout.java
/**
 * Swap gravity:
 * left for bottom
 * right for top
 * center horizontal for center vertical
 * etc
 * <p>
 * also swap left|right padding for bottom|top
 */
private void fixGravityAndPadding(int direction)
{
    for (int i = 0; i < getChildCount(); i++)
    {
        // gravity swap
        View v = getChildAt(i);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) v.getLayoutParams();
        int gravity = layoutParams.gravity;

        if (direction == LinearLayout.VERTICAL)
        {
            if ((gravity & Gravity.LEFT) != 0)
            {   // if gravity left is set . . .
                gravity &= ~Gravity.LEFT;          // unset left
                gravity |= Gravity.BOTTOM;         // and set bottom
            }
        } else
        {
            if ((gravity & Gravity.BOTTOM) != 0)
            { // etc
                gravity &= ~Gravity.BOTTOM;
                gravity |= Gravity.LEFT;
            }
        }

        if (direction == LinearLayout.VERTICAL)
        {
            if ((gravity & Gravity.RIGHT) != 0)
            {
                gravity &= ~Gravity.RIGHT;
                gravity |= Gravity.TOP;
            }
        } else
        {
            if ((gravity & Gravity.TOP) != 0)
            {
                gravity &= ~Gravity.TOP;
                gravity |= Gravity.RIGHT;
            }
        }

        // don't mess with children that are centered in both directions
        if ((gravity & Gravity.CENTER) != Gravity.CENTER)
        {
            if (direction == LinearLayout.VERTICAL)
            {
                if ((gravity & Gravity.CENTER_VERTICAL) != 0)
                {
                    gravity &= ~Gravity.CENTER_VERTICAL;
                    gravity |= Gravity.CENTER_HORIZONTAL;
                }
            } else
            {
                if ((gravity & Gravity.CENTER_HORIZONTAL) != 0)
                {
                    gravity &= ~Gravity.CENTER_HORIZONTAL;
                    gravity |= Gravity.CENTER_VERTICAL;
                }
            }
        }

        layoutParams.gravity = gravity;

        // padding swap
        int paddingLeft = v.getPaddingLeft();
        int paddingTop = v.getPaddingTop();
        int paddingRight = v.getPaddingRight();
        int paddingBottom = v.getPaddingBottom();
        v.setPadding(paddingBottom, paddingRight, paddingTop, paddingLeft);
    }
}
 
源代码20 项目: Android-utils   文件: ViewUtils.java
/**
 * 对 View 设置 paddingLeft
 *
 * @param view  需要被设置的 View
 * @param value 设置的值
 */
public static void setPaddingLeft(View view, int value) {
    if (value != view.getPaddingLeft()) {
        view.setPadding(value, view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
    }
}
 
 方法所在类
 同类方法