微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.text.BoringLayout的实例源码

项目:CommentView    文件CanvasTextArea.java   
private Layout makeNewLayout(int i,BoringLayout.Metrics metrics,int i2,boolean z) {
    int i3;
    boolean z2;
    if (i < 0) {
        i3 = 0;
    } else {
        i3 = i;
    }
    this.mOldMaxLines = this.mMaxLines;
    if (this.mEllipsize != null) {
        z2 = true;
    } else {
        z2 = false;
    }
    return makeSingleLayout(i3,metrics,i2,this.mLayoutAlignment,z2,this.mEllipsize,z);
}
项目:CommentView    文件CanvasTextArea.java   
private Layout makeSingleLayout(int i,Alignment alignment,boolean z,TextUtils.TruncateAt truncateAt,boolean z2) {
    BoringLayout.Metrics isBoring;
    if (metrics == UNKNowN_BORING) {
        isBoring = BoringLayout.isBoring(this.mText,this.mPaint,this.mBoring);
        if (isBoring != null) {
            this.mBoring = isBoring;
        }
    } else {
        isBoring = metrics;
    }
    if (isBoring != null) {
        if (isBoring.width <= i && (truncateAt == null || isBoring.width <= i2)) {
            return BoringLayout.make(this.mText,i,alignment,this.mLinespacingMult,this.mLinespacingAdd,isBoring,this.mIncludeFontPadding);
        } else if (z && isBoring.width <= i) {
            return BoringLayout.make(this.mText,this.mIncludeFontPadding,truncateAt,i2);
        } else if (z) {
            return StaticLayoutWithMaxLines.create(this.mText,this.mText.length(),this.mMaxLines);
        } else {
            return new StaticLayout(this.mText,this.mIncludeFontPadding);
        }
    } else if (z) {
        return StaticLayoutWithMaxLines.create(this.mText,this.mMaxLines);
    } else {
        return new StaticLayout(this.mText,this.mIncludeFontPadding);
    }
}
项目:MDPreference    文件ContactChipDrawable.java   
public ContactChipDrawable(int paddingLeft,int paddingRight,Typeface typeface,int textColor,int textSize,int backgroundColor) {
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(textColor);
    mPaint.setTypeface(typeface);
    mPaint.setTextSize(textSize);

    mTextPaint = new TextPaint(mPaint);
    mMetrics = new BoringLayout.Metrics();
    Paint.FontMetricsInt temp = mTextPaint.getFontMetricsInt();
    mMetrics.ascent = temp.ascent;
    mMetrics.bottom = temp.bottom;
    mMetrics.descent = temp.descent;
    mMetrics.top = temp.top;
    mMetrics.leading = temp.leading;

    mRect = new RectF();

    mMatrix = new Matrix();

    mPaddingLeft = paddingLeft;
    mPaddingRight = paddingRight;
    mBackgroundColor = backgroundColor;
}
项目:MDPreference    文件ContactChipDrawable.java   
private void updateLayout(){
    if(mContactName == null)
        return;

    Rect bounds = getBounds();
    if(bounds.width() == 0 || bounds.height() == 0)
        return;

    int outerWidth = Math.max(0,bounds.width() - bounds.height() - mPaddingLeft - mPaddingRight);
    mMetrics.width = Math.round(mTextPaint.measureText(mContactName,mContactName.length()) + 0.5f);

    if(mBoringLayout == null)
        mBoringLayout = BoringLayout.make(mContactName,mTextPaint,outerWidth,Layout.Alignment.ALIGN_norMAL,1f,mMetrics,true,TextUtils.TruncateAt.END,outerWidth);
    else
        mBoringLayout = mBoringLayout.replaceOrMake(mContactName,outerWidth);
}
项目:CustomEQView    文件HorizontalPicker.java   
/**
 * Sets values to choose from
 * @param values New values to choose from
 */
public void setValues(CharSequence[] values) {

    if (this.values != values) {
        this.values = values;

        if (this.values != null) {
            layouts = new BoringLayout[this.values.length];
            for (int i = 0; i < layouts.length; i++) {
                layouts[i] = new BoringLayout(this.values[i],textPaint,itemWidth,Layout.Alignment.ALIGN_CENTER,boringMetrics,false,ellipsize,itemWidth);
            }
        } else {
            layouts = new BoringLayout[0];
        }

        // start marque only if has already been measured
        if (getWidth() > 0) {
            startMarqueeIfNeeded();
        }

        requestLayout();
        invalidate();
    }

}
项目:MyAndroidDemo    文件HorizontalPicker.java   
/**
 * Sets values to choose from
 * @param values New values to choose from
 */
public void setValues(CharSequence[] values) {

    if (this.values != values) {
        this.values = values;

        if (this.values != null) {
            layouts = new BoringLayout[this.values.length];
            for (int i = 0; i < layouts.length; i++) {
                layouts[i] = new BoringLayout(this.values[i],itemWidth);
            }
        } else {
            layouts = new BoringLayout[0];
        }

        // start marque only if has already been measured
        if (getWidth() > 0) {
            startMarqueeIfNeeded();
        }

        requestLayout();
        invalidate();
    }

}
项目:material-master    文件ContactChipDrawable.java   
public ContactChipDrawable(int paddingLeft,int backgroundColor) {
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(textColor);
    mPaint.setTypeface(typeface);
    mPaint.setTextSize(textSize);

    mTextPaint = new TextPaint(mPaint);
    mMetrics = new BoringLayout.Metrics();
    Paint.FontMetricsInt temp = mTextPaint.getFontMetricsInt();
    mMetrics.ascent = temp.ascent;
    mMetrics.bottom = temp.bottom;
    mMetrics.descent = temp.descent;
    mMetrics.top = temp.top;
    mMetrics.leading = temp.leading;

    mRect = new RectF();

    mMatrix = new Matrix();

    mPaddingLeft = paddingLeft;
    mPaddingRight = paddingRight;
    mBackgroundColor = backgroundColor;
}
项目:material-master    文件ContactChipDrawable.java   
private void updateLayout(){
    if(mContactName == null)
        return;

    Rect bounds = getBounds();
    if(bounds.width() == 0 || bounds.height() == 0)
        return;

    int outerWidth = Math.max(0,bounds.width() - bounds.height() - mPaddingLeft - mPaddingRight);
    mMetrics.width = (int) FloatMath.ceil(mTextPaint.measureText(mContactName,mContactName.length()));

    if(mBoringLayout == null)
        mBoringLayout = BoringLayout.make(mContactName,outerWidth);
}
项目:material_fork    文件ContactChipDrawable.java   
public ContactChipDrawable(int paddingLeft,int backgroundColor) {
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(textColor);
    mPaint.setTypeface(typeface);
    mPaint.setTextSize(textSize);

    mTextPaint = new TextPaint(mPaint);
    mMetrics = new BoringLayout.Metrics();
    Paint.FontMetricsInt temp = mTextPaint.getFontMetricsInt();
    mMetrics.ascent = temp.ascent;
    mMetrics.bottom = temp.bottom;
    mMetrics.descent = temp.descent;
    mMetrics.top = temp.top;
    mMetrics.leading = temp.leading;

    mRect = new RectF();

    mMatrix = new Matrix();

    mPaddingLeft = paddingLeft;
    mPaddingRight = paddingRight;
    mBackgroundColor = backgroundColor;
}
项目:material_fork    文件ContactChipDrawable.java   
private void updateLayout(){
    if(mContactName == null)
        return;

    Rect bounds = getBounds();
    if(bounds.width() == 0 || bounds.height() == 0)
        return;

    int outerWidth = Math.max(0,outerWidth);
}
项目:Material-Components    文件ContactChipDrawable.java   
public ContactChipDrawable(int paddingLeft,int backgroundColor) {
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(textColor);
    mPaint.setTypeface(typeface);
    mPaint.setTextSize(textSize);

    mTextPaint = new TextPaint(mPaint);
    mMetrics = new BoringLayout.Metrics();
    Paint.FontMetricsInt temp = mTextPaint.getFontMetricsInt();
    mMetrics.ascent = temp.ascent;
    mMetrics.bottom = temp.bottom;
    mMetrics.descent = temp.descent;
    mMetrics.top = temp.top;
    mMetrics.leading = temp.leading;

    mRect = new RectF();

    mMatrix = new Matrix();

    mPaddingLeft = paddingLeft;
    mPaddingRight = paddingRight;
    mBackgroundColor = backgroundColor;
}
项目:Material-Components    文件ContactChipDrawable.java   
private void updateLayout(){
    if(mContactName == null)
        return;

    Rect bounds = getBounds();
    if(bounds.width() == 0 || bounds.height() == 0)
        return;

    int outerWidth = Math.max(0,outerWidth);
}
项目:CommentView    文件CanvasTextArea.java   
protected void onMeasure(int i,int i2) {
    String generateCacheKey = generateCacheKey();
    this.mCacheText = (TextCache) getAreaCache(generateCacheKey);
    if (this.mCacheText == null || this.mCacheText.mLayout == null || this.mMeasureDirty) {
        this.mCacheText = new TextCache();
        addAreaCache(generateCacheKey,this.mCacheText);
        int mode = View.MeasureSpec.getMode(i);
        int mode2 = View.MeasureSpec.getMode(i2);
        int size = View.MeasureSpec.getSize(i);
        int size2 = View.MeasureSpec.getSize(i2);
        if (mode == 1073741824) {
            this.mCacheText.measuredWidth = size;
        } else {
            this.mBoring = BoringLayout.isBoring(this.mText,UNKNowN_BORING);
            if (this.mBoring == null || this.mBoring == UNKNowN_BORING) {
                this.mCacheText.measuredWidth = (int) Layout.getDesiredWidth(this.mText,this.mPaint);
            } else {
                this.mCacheText.measuredWidth = this.mBoring.width;
            }
            TextCache textCache = this.mCacheText;
            textCache.measuredWidth = textCache.measuredWidth + (this.paddingLeft + this.paddingRight);
            if (mode == Integer.MIN_VALUE) {
                this.mCacheText.measuredWidth = Math.min(size,this.mCacheText.measuredWidth);
            }
        }
        mode = (this.mCacheText.measuredWidth - this.paddingLeft) - this.paddingRight;
        this.mCacheText.mLayout = makeNewLayout(mode,this.mBoring,mode,false);
        if (mode2 == 1073741824) {
            this.mCacheText.measuredHeight = size2;
        } else {
            this.mCacheText.measuredHeight = getDesiredHeight();
            if (mode2 == Integer.MIN_VALUE) {
                this.mCacheText.measuredHeight = Math.min(size2,this.mCacheText.measuredHeight);
            }
        }
        setMeasuredDimension(this.mCacheText.measuredWidth,this.mCacheText.measuredHeight);
        return;
    }
    setMeasuredDimension(this.mCacheText.measuredWidth,this.mCacheText.measuredHeight);
}
项目:FastTextView    文件SingleLineTextView.java   
@Override
protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) {
  if (mLayout == null && !TextUtils.isEmpty(mText)) {
    BoringLayout.Metrics fm = new BoringLayout.Metrics();
    fm.width = (int) Layout.getDesiredWidth(mText,mTextPaint);
    mLayout = BoringLayout.make(mText,MeasureSpec.getSize(widthMeasureSpec),TextViewAttrsHelper.getLayoutAlignment(this,getGravity()),mAttrsHelper.mSpacingMultiplier,mAttrsHelper.mSpacingAdd,fm,true);
  }
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
}
项目:MDPreference    文件ContactChipSpan.java   
public ContactChipSpan(CharSequence name,int height,int maxWidth,int paddingLeft,int backgroundColor) {
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(textColor);
    mPaint.setTypeface(typeface);
    mPaint.setTextSize(textSize);

    mTextPaint = new TextPaint(mPaint);


    mRect = new RectF();

    mMatrix = new Matrix();

    mContactName = name;
    mPaddingLeft = paddingLeft;
    mPaddingRight = paddingRight;
    mBackgroundColor = backgroundColor;
    mHeight = height;
    mWidth = Math.round(Math.min(maxWidth,mPaint.measureText(name,name.length()) + paddingLeft + paddingRight + height));

    int outerWidth = Math.max(0,mWidth - mPaddingLeft - mPaddingRight - mHeight);
    Paint.FontMetricsInt temp = mTextPaint.getFontMetricsInt();
    BoringLayout.Metrics mMetrics = new BoringLayout.Metrics();
    mMetrics.width = Math.round(mTextPaint.measureText(mContactName,mContactName.length()) + 0.5f);
    mMetrics.ascent = temp.ascent;
    mMetrics.bottom = temp.bottom;
    mMetrics.descent = temp.descent;
    mMetrics.top = temp.top;
    mMetrics.leading = temp.leading;
    mBoringLayout = BoringLayout.make(mContactName,outerWidth);
}
项目:WeekDatePicker    文件WeekDatePicker.java   
private static BoringLayout.Metrics toBoringFontMetrics(FontMetricsInt metrics,@Nullable BoringLayout.Metrics fontMetrics) {

    if (fontMetrics == null) {
        fontMetrics = new BoringLayout.Metrics();
    }

    fontMetrics.ascent = metrics.ascent;
    fontMetrics.bottom = metrics.bottom;
    fontMetrics.descent = metrics.descent;
    fontMetrics.leading = metrics.leading;
    fontMetrics.top = metrics.top;
    return fontMetrics;
}
项目:subtextview    文件SubTextView.java   
private Layout obtainLayout(CharSequence source,TextPaint paint,int widthMeasureSpec,boolean isSubtitle) {
    int width = MeasureSpec.getSize(widthMeasureSpec) - super.getCompoundPaddingLeft() - super.getCompoundPaddingRight();
    BoringLayout.Metrics metrics = BoringLayout.isBoring(source,paint);
    Layout.Alignment alignment = isSubtitle ? Layout.Alignment.ALIGN_norMAL : Layout.Alignment.ALIGN_OPPOSITE;
    if (metrics != null) {
        return BoringLayout.make(source,paint,width,1.0f,false);
    } else {
        return new StaticLayout(source,false);
    }
}
项目:material-master    文件ContactChipSpan.java   
public ContactChipSpan(CharSequence name,mWidth - mPaddingLeft - mPaddingRight - mHeight);
    Paint.FontMetricsInt temp = mTextPaint.getFontMetricsInt();
    BoringLayout.Metrics mMetrics = new BoringLayout.Metrics();
    mMetrics.width = (int)FloatMath.ceil(mTextPaint.measureText(mContactName,mContactName.length()));
    mMetrics.ascent = temp.ascent;
    mMetrics.bottom = temp.bottom;
    mMetrics.descent = temp.descent;
    mMetrics.top = temp.top;
    mMetrics.leading = temp.leading;
    mBoringLayout = BoringLayout.make(mContactName,outerWidth);
}
项目:material_fork    文件ContactChipSpan.java   
public ContactChipSpan(CharSequence name,outerWidth);
}
项目:CanvasLayout    文件TextElement.java   
private void makeNewLayout(int wantWidth,BoringLayout.Metrics boring,int ellipsisWidth,boolean bringIntoView) {
    if (wantWidth < 0) {
        wantWidth = 0;
    }

    mOldMaxLines = mMaxLines;
    boolean shouldEllipsize = (mEllipsize != null);

    mLayout = makeSingleLayout(wantWidth,boring,ellipsisWidth,mLayoutAlignment,shouldEllipsize,mEllipsize,bringIntoView);
}
项目:Material-Components    文件ContactChipSpan.java   
public ContactChipSpan(CharSequence name,outerWidth);
}
项目:ReactNativeSignatureExample    文件ReactTextShadowNode.java   
@Override
public void measure(CSSNode node,float width,float height,MeasureOutput measureOutput) {
  // Todo(5578671): Handle text direction (see View#getTextDirectionHeuristic)
  ReactTextShadowNode reactCSSNode = (ReactTextShadowNode) node;
  TextPaint textPaint = sTextPaintInstance;
  Layout layout;
  Spanned text = Assertions.assertNotNull(
      reactCSSNode.mPreparedSpannableText,"Spannable element has not been prepared in onBeforeLayout");
  BoringLayout.Metrics boring = BoringLayout.isBoring(text,textPaint);
  float desiredWidth = boring == null ?
      Layout.getDesiredWidth(text,textPaint) : Float.NaN;

  if (boring == null &&
      (CSSConstants.isUndefined(width) ||
          (!CSSConstants.isUndefined(desiredWidth) && desiredWidth <= width))) {
    // Is used when the width is not kNown and the text is not boring,ie. if it contains
    // unicode characters.
    layout = new StaticLayout(
        text,(int) Math.ceil(desiredWidth),1,true);
  } else if (boring != null && (CSSConstants.isUndefined(width) || boring.width <= width)) {
    // Is used for single-line,boring text when the width is either unkNown or bigger
    // than the width of the text.
    layout = BoringLayout.make(
        text,boring.width,true);
  } else {
    // Is used for multiline,boring text and the width is kNown.
    layout = new StaticLayout(
        text,(int) width,true);
  }

  measureOutput.height = layout.getHeight();
  measureOutput.width = layout.getWidth();
  if (reactCSSNode.mNumberOfLines != UNSET &&
      reactCSSNode.mNumberOfLines < layout.getLineCount()) {
    measureOutput.height = layout.getLineBottom(reactCSSNode.mNumberOfLines - 1);
  }
  if (reactCSSNode.mLineHeight != UNSET) {
    int lines = reactCSSNode.mNumberOfLines != UNSET
        ? Math.min(reactCSSNode.mNumberOfLines,layout.getLineCount())
        : layout.getLineCount();
    float lineHeight = PixelUtil.toPixelFromSP(reactCSSNode.mLineHeight);
    measureOutput.height = lineHeight * lines;
  }
}
项目:react-native-ibeacon-android    文件ReactTextShadowNode.java   
@Override
public void measure(CSSNode node,layout.getLineCount())
        : layout.getLineCount();
    float lineHeight = PixelUtil.toPixelFromSP(reactCSSNode.mLineHeight);
    measureOutput.height = lineHeight * lines;
  }
}
项目:WeekDatePicker    文件WeekDatePicker.java   
private void drawWeek(Canvas canvas,int layoutIndex,int weekOffset) {

        int saveCount = canvas.save();

        int labelHeight = dayLabelLayouts[0].getHeight();
        float circleRadius = dayWidth / 3;
        int centerY = layouts[0].getHeight() / 2;
        float dateLineOffset = circleRadius - centerY;

        for (int i = 0; i < 7; i++) {

            int itemIndex = weekOffset * 7 + i;
            BoringLayout layout = layouts[layoutIndex + i];
            BoringLayout labelLayout = dayLabelLayouts[i];

            dayLabelTextPain.setColor(getTextColor(dayLabelTextColor,itemIndex));
            labelLayout.draw(canvas);

            dayTextPaint.setColor(getTextColor(dayTextColor,itemIndex));

            int count = canvas.save();
            canvas.translate(0,labelHeight + dateLineOffset + labelPadding);

            if (dayDrawable != null) {
                dayDrawable.setBounds(backgroundRect);
                dayDrawable.setState(getItemDrawableState(itemIndex));
                dayDrawable.draw(canvas);
            }

            if (indicatorDrawable != null && dayIndicators.get(itemIndex - dayDelta,false)) {
                indicatorDrawable.setBounds(indicatorRect);
                indicatorDrawable.setState(getItemDrawableState(itemIndex));
                indicatorDrawable.draw(canvas);
            }

            layout.draw(canvas);

            canvas.restoretoCount(count);

            canvas.translate(dayWidth,0);
        }

        canvas.restoretoCount(saveCount);

    }
项目:WeekDatePicker    文件WeekDatePicker.java   
private void remakeLayout() {

        if (getWidth() > 0)  {

            LocalDate day = getRelativeFirstDay(-1);

            for (int i = 0; i < layouts.length; i++) {

                String dayText = String.valueOf(day.getDayOfMonth());
                if (layouts[i] == null) {
                    layouts[i] = BoringLayout.make(dayText,dayTextPaint,dayWidth,dayMetrics,dayWidth);
                } else {
                    layouts[i].replaceOrMake(dayText,dayWidth);
                }

                day = day.plusDays(1);
            }

            DayOfWeek dayOfWeek = firstDayOfWeek; // first index is 1
            for (int i = 0; i < dayLabelLayouts.length; i++) {

                CharSequence name;
                if (labelNames == null) {
                    name = dayOfWeek.getdisplayName(TextStyle.SHORT,Locale.getDefault());
                } else {
                    int index = dayOfWeek.getValue() - 1;
                    name = labelNames[index];
                }


                if (dayLabelLayouts[i] == null) {
                    dayLabelLayouts[i] = BoringLayout.make(name,dayLabelTextPain,dayLabelMetrics,dayWidth);
                } else {
                    dayLabelLayouts[i].replaceOrMake(name,dayWidth);
                }

                dayOfWeek = dayOfWeek.plus(1);

            }

        }

    }
项目:react-native-Box-loaders    文件ReactTextShadowNode.java   
@Override
public void measure(
    CSSNode node,CSSMeasureMode widthMode,CSSMeasureMode heightMode,textPaint) : Float.NaN;

  // technically,width should never be negative,but there is currently a bug in
  boolean unconstrainedWidth = widthMode == CSSMeasureMode.UNDEFINED || width < 0;

  if (boring == null &&
      (unconstrainedWidth ||
          (!CSSConstants.isUndefined(desiredWidth) && desiredWidth <= width))) {
    // Is used when the width is not kNown and the text is not boring,true);
  } else if (boring != null && (unconstrainedWidth || boring.width <= width)) {
    // Is used for single-line,layout.getLineCount())
        : layout.getLineCount();
    float lineHeight = PixelUtil.toPixelFromSP(reactCSSNode.mLineHeight);
    measureOutput.height = lineHeight * lines;
  }
}
项目:Ironman    文件ReactTextShadowNode.java   
@Override
public void measure(
    CSSNodeAPI node,1.f,0.f,true);
  }

  measureOutput.height = layout.getHeight();
  measureOutput.width = layout.getWidth();
  if (reactCSSNode.mNumberOfLines != UNSET &&
      reactCSSNode.mNumberOfLines < layout.getLineCount()) {
    measureOutput.height = layout.getLineBottom(reactCSSNode.mNumberOfLines - 1);
  }
}
项目:CustomEQView    文件HorizontalPicker.java   
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    int saveCount = canvas.getSaveCount();
    canvas.save();

    int selectedItem = this.selectedItem;

    float itemWithPadding = itemWidth + dividerSize;

    // translate horizontal to center
    canvas.translate(itemWithPadding * sideItems,0);

    if (values != null) {
        for (int i = 0; i < values.length; i++) {

            // set text color for item
            textPaint.setColor(getTextColor(i));
            textPaint.setTextSize(getTextSize(i));
            // get text layout
            BoringLayout layout = layouts[i];

            int saveCountHeight = canvas.getSaveCount();
            canvas.save();

            float x = 0;

            float linewidth = layout.getlinewidth(0);
            if (linewidth > itemWidth) {
                if (isRtl(values[i])) {
                    x += (linewidth - itemWidth) / 2;
                } else {
                    x -= (linewidth - itemWidth) / 2;
                }
            }

            if (marquee != null && i == selectedItem) {
                x += marquee.getScroll();
            }

            // translate vertically to center
            canvas.translate(-x,(canvas.getHeight() - layout.getHeight()) / 2);

            RectF clipBounds;
            if (x == 0) {
                clipBounds = itemClipBounds;
            } else {
                clipBounds = itemClipBoundsOffset;
                clipBounds.set(itemClipBounds);
                clipBounds.offset(x,0);
            }

            canvas.clipRect(clipBounds);
            layout.draw(canvas);

            if (marquee != null && i == selectedItem && marquee.shouldDrawGhost()) {
                canvas.translate(marquee.getGhostOffset(),0);
                layout.draw(canvas);
            }

            // restore vertical translation
            canvas.restoretoCount(saveCountHeight);

            // translate horizontal for 1 item
            canvas.translate(itemWithPadding,0);
        }
    }

    // restore horizontal translation
    canvas.restoretoCount(saveCount);

    drawEdgeEffect(canvas,leftEdgeEffect,270);
    drawEdgeEffect(canvas,rightEdgeEffect,90);
}
项目:MyAndroidDemo    文件HorizontalPicker.java   
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    int saveCount = canvas.getSaveCount();
    canvas.save();

    int selectedItem = this.selectedItem;

    float itemWithPadding = itemWidth + dividerSize;

    // translate horizontal to center
    canvas.translate(itemWithPadding * sideItems,90);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。