当前位置: 首页>>代码示例>>Java>>正文


Java BoringLayout类代码示例

本文整理汇总了Java中android.text.BoringLayout的典型用法代码示例。如果您正苦于以下问题:Java BoringLayout类的具体用法?Java BoringLayout怎么用?Java BoringLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BoringLayout类属于android.text包,在下文中一共展示了BoringLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeSingleLayout

import android.text.BoringLayout; //导入依赖的package包/类
private Layout makeSingleLayout(int i, BoringLayout.Metrics metrics, int i2, 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, this.mPaint, i, alignment, this.mLineSpacingMult, this.mLineSpacingAdd, isBoring, this.mIncludeFontPadding);
        } else if (z && isBoring.width <= i) {
            return BoringLayout.make(this.mText, this.mPaint, i, alignment, this.mLineSpacingMult, this.mLineSpacingAdd, isBoring, this.mIncludeFontPadding, truncateAt, i2);
        } else if (z) {
            return StaticLayoutWithMaxLines.create(this.mText, 0, this.mText.length(), this.mPaint, i, alignment, this.mLineSpacingMult, this.mLineSpacingAdd, this.mIncludeFontPadding, truncateAt, i2, this.mMaxLines);
        } else {
            return new StaticLayout(this.mText, this.mPaint, i, alignment, this.mLineSpacingMult, this.mLineSpacingAdd, this.mIncludeFontPadding);
        }
    } else if (z) {
        return StaticLayoutWithMaxLines.create(this.mText, 0, this.mText.length(), this.mPaint, i, alignment, this.mLineSpacingMult, this.mLineSpacingAdd, this.mIncludeFontPadding, truncateAt, i2, this.mMaxLines);
    } else {
        return new StaticLayout(this.mText, this.mPaint, i, alignment, this.mLineSpacingMult, this.mLineSpacingAdd, this.mIncludeFontPadding);
    }
}
 
开发者ID:xieyangxuejun,项目名称:CommentView,代码行数:27,代码来源:CanvasTextArea.java

示例2: ContactChipDrawable

import android.text.BoringLayout; //导入依赖的package包/类
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;
}
 
开发者ID:XhinLiang,项目名称:MDPreference,代码行数:25,代码来源:ContactChipDrawable.java

示例3: updateLayout

import android.text.BoringLayout; //导入依赖的package包/类
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, 0, mContactName.length()) + 0.5f);

    if(mBoringLayout == null)
        mBoringLayout = BoringLayout.make(mContactName, mTextPaint, outerWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 1f, mMetrics, true, TextUtils.TruncateAt.END, outerWidth);
    else
        mBoringLayout = mBoringLayout.replaceOrMake(mContactName, mTextPaint, outerWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 1f, mMetrics, true, TextUtils.TruncateAt.END, outerWidth);
}
 
开发者ID:XhinLiang,项目名称:MDPreference,代码行数:17,代码来源:ContactChipDrawable.java

示例4: setValues

import android.text.BoringLayout; //导入依赖的package包/类
/**
 * 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,
                        1f, 1f, boringMetrics, false, ellipsize, itemWidth);
            }
        } else {
            layouts = new BoringLayout[0];
        }

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

        requestLayout();
        invalidate();
    }

}
 
开发者ID:iOnesmile,项目名称:CustomEQView,代码行数:30,代码来源:HorizontalPicker.java

示例5: updateLayout

import android.text.BoringLayout; //导入依赖的package包/类
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, 0, mContactName.length()));

    if(mBoringLayout == null)
        mBoringLayout = BoringLayout.make(mContactName, mTextPaint, outerWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 1f, mMetrics, true, TextUtils.TruncateAt.END, outerWidth);
    else
        mBoringLayout = mBoringLayout.replaceOrMake(mContactName, mTextPaint, outerWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 1f, mMetrics, true, TextUtils.TruncateAt.END, outerWidth);
}
 
开发者ID:iamzhangdejian,项目名称:material-master,代码行数:17,代码来源:ContactChipDrawable.java

示例6: makeNewLayout

import android.text.BoringLayout; //导入依赖的package包/类
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);
}
 
开发者ID:xieyangxuejun,项目名称:CommentView,代码行数:17,代码来源:CanvasTextArea.java

示例7: onMeasure

import android.text.BoringLayout; //导入依赖的package包/类
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, this.mPaint, 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);
}
 
开发者ID:xieyangxuejun,项目名称:CommentView,代码行数:41,代码来源:CanvasTextArea.java

示例8: onMeasure

import android.text.BoringLayout; //导入依赖的package包/类
@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, mTextPaint, MeasureSpec.getSize(widthMeasureSpec),
        TextViewAttrsHelper.getLayoutAlignment(this, getGravity()), mAttrsHelper.mSpacingMultiplier, mAttrsHelper.mSpacingAdd, fm, true);
  }
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
 
开发者ID:lsjwzh,项目名称:FastTextView,代码行数:11,代码来源:SingleLineTextView.java

示例9: ContactChipSpan

import android.text.BoringLayout; //导入依赖的package包/类
public ContactChipSpan(CharSequence name, int height, int maxWidth, 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);


    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, 0, 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, 0, 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, mTextPaint, outerWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 1f, mMetrics, true, TextUtils.TruncateAt.END, outerWidth);
}
 
开发者ID:XhinLiang,项目名称:MDPreference,代码行数:33,代码来源:ContactChipSpan.java

示例10: toBoringFontMetrics

import android.text.BoringLayout; //导入依赖的package包/类
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;
}
 
开发者ID:blazsolar,项目名称:WeekDatePicker,代码行数:15,代码来源:WeekDatePicker.java

示例11: obtainLayout

import android.text.BoringLayout; //导入依赖的package包/类
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, alignment, 1.0f, 0, metrics, false);
    } else {
        return new StaticLayout(source, paint, width, alignment, 1.0f, 0, false);
    }
}
 
开发者ID:czy1121,项目名称:subtextview,代码行数:11,代码来源:SubTextView.java

示例12: ContactChipSpan

import android.text.BoringLayout; //导入依赖的package包/类
public ContactChipSpan(CharSequence name, int height, int maxWidth, 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);


    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, 0, 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 = (int)FloatMath.ceil(mTextPaint.measureText(mContactName, 0, 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, mTextPaint, outerWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 1f, mMetrics, true, TextUtils.TruncateAt.END, outerWidth);
}
 
开发者ID:iamzhangdejian,项目名称:material-master,代码行数:33,代码来源:ContactChipSpan.java

示例13: makeNewLayout

import android.text.BoringLayout; //导入依赖的package包/类
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);
}
 
开发者ID:nicai1900,项目名称:CanvasLayout,代码行数:13,代码来源:TextElement.java

示例14: measure

import android.text.BoringLayout; //导入依赖的package包/类
@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,
        textPaint,
        (int) Math.ceil(desiredWidth),
        Layout.Alignment.ALIGN_NORMAL,
        1,
        0,
        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,
        textPaint,
        boring.width,
        Layout.Alignment.ALIGN_NORMAL,
        1,
        0,
        boring,
        true);
  } else {
    // Is used for multiline, boring text and the width is known.
    layout = new StaticLayout(
        text,
        textPaint,
        (int) width,
        Layout.Alignment.ALIGN_NORMAL,
        1,
        0,
        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;
  }
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:65,代码来源:ReactTextShadowNode.java

示例15: drawWeek

import android.text.BoringLayout; //导入依赖的package包/类
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);

    }
 
开发者ID:blazsolar,项目名称:WeekDatePicker,代码行数:46,代码来源:WeekDatePicker.java


注:本文中的android.text.BoringLayout类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。