the padding, so 0,0 is where we start drawing d.setBounds(0, 0, w - mPaddingRight - mPaddingLeft...private void setThumbPos(int w, Drawable thumb, float scale, int gap) { int available = w - mPaddingLeft..., we need to allow the thumb to // draw in its extra space canvas.translate(mPaddingLeft...int x = (int)event.getX(); float scale; float progress = 0; if (x < mPaddingLeft...width - mPaddingRight) { scale = 1.0f; } else { scale = (float)(x - mPaddingLeft
private int mPaddingTop; private int mPaddingBottom; private int mPaddingLeft; private int mPaddingRight...super.onDraw(canvas); mPaddingTop = getPaddingTop(); mPaddingBottom = getPaddingBottom(); mPaddingLeft...mUsableHeight = getHeight() - mPaddingTop - mPaddingBottom; // 画笔起始点要考虑padding mUsableStartX = mPaddingLeft...super.onDraw(canvas); mPaddingTop = getPaddingTop(); mPaddingBottom = getPaddingBottom(); mPaddingLeft...mUsableHeight = getHeight() - mPaddingTop - mPaddingBottom; // 画笔起始点要考虑padding mUsableStartX = mPaddingLeft
Override public void onDraw(Canvas canvas) { super.onDraw(canvas); //获取padding,然后根据实际情况处理就好 mPaddingLeft...mPaddingTop = getPaddingTop(); mPaddingBottom = getPaddingBottom(); mWidth = getWidth() - mPaddingLeft
= MeasureSpec.EXACTLY) { maxWidth = alternativeMaxWidth; } maxWidth += mPaddingLeft
方法,保证绘制的是圆 包正绘图是圆形的前提是: 保证 RectF 切割的是正方形, 那么保证 RextF 围成的是正方形,就要需要知道正方形四边距离控件边界的距离 也就是我们需要计算四个整型变量 :1.mPaddingLeft...加一个默认的padding值,为了防止用camera旋转时钟时造成四周超出view大小 */ private float mDefaultPadding; private float mPaddingLeft...getPaddingTop() - getPaddingBottom()) / 2;// 各个指针长度 mDefaultPadding = 0.12f * mRadius; mPaddingLeft
desiredAspect = (float) w / (float) h; } } int pleft = mPaddingLeft...// nothing to draw (empty bounds) } if (mDrawMatrix == null && mPaddingTop == 0 && mPaddingLeft...= mScrollX; final int scrollY = mScrollY; canvas.clipRect(scrollX + mPaddingLeft...scrollY + mBottom - mTop - mPaddingBottom); } canvas.translate(mPaddingLeft...int dwidth = mDrawableWidth; int dheight = mDrawableHeight; int vwidth = getWidth() - mPaddingLeft
final int childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, mPaddingLeft
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft
得到子View的宽的MeasureSpec final int childWidthMeasureSpec = getChildMeasureSpec (parentWidthMeasureSpec,mPaddingLeft...* 在measureChildWithMargins()方法里调用getChildMeasureSpec()时注意第二个参数的构成: * 比如:mPaddingLeft + mPaddingRight...+ lp.leftMargin + lp.rightMargin * 其中: * mPaddingLeft和mPaddingRight表示父容器左右两内侧的padding * lp.leftMargin
(); } final Rect listPadding = mListPadding; listPadding.left = mSelectionLeftPadding + mPaddingLeft
> 0) { View child = getChildAt(0); x = clamp(x, getWidth() - mPaddingRight - mPaddingLeft
(); final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...margin final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft... } } void layoutVertical(int left, int top, int right, int bottom) { final int paddingLeft = mPaddingLeft...clipToPadding) { clipSaveCount = canvas.save(Canvas.CLIP_SAVE_FLAG); canvas.clipRect(mScrollX + mPaddingLeft
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft
weightedMaxWidth); } // padding 都是 0 maxWidth += mPaddingLeft...void layoutVertical(int left, int top, int right, int bottom) { final int paddingLeft = mPaddingLeft
= null) { canvas.save(); canvas.translate(scrollX + mPaddingLeft + leftOffset, scrollY
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...//最大宽度加上左右margin maxWidth += mPaddingLeft + mPaddingRight; // Check against our minimum...(): void layoutVertical(int left, int top, int right, int bottom) { final int paddingLeft = mPaddingLeft
if (duration > ANIMATED_SCROLL_GAP) { final int width = getWidth() - mPaddingRight - mPaddingLeft
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...float rightFadeStrength = 0.0f; // Step 2, save the canvas' layers int paddingLeft = mPaddingLeft
child.getLayoutParams(); final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft...mBottom-mTop; if (mForegroundInPadding) { selfBounds.set(0, 0, w, h); } else { selfBounds.set(mPaddingLeft...leftFadeStrength = 0.0f; float rightFadeStrength = 0.0f; // Step 2, save the canvas' layers int paddingLeft = mPaddingLeft...CLIP_TO_PADDING_MASK; if (clipToPadding) { clipSaveCount = canvas.save(); canvas.clipRect(mScrollX + mPaddingLeft
child.getLayoutParams(); final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft
领取专属 10元无门槛券
手把手带您无忧上云