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


Java Alignment.ALIGN_NORMAL属性代码示例

本文整理汇总了Java中android.text.Layout.Alignment.ALIGN_NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Java Alignment.ALIGN_NORMAL属性的具体用法?Java Alignment.ALIGN_NORMAL怎么用?Java Alignment.ALIGN_NORMAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.text.Layout.Alignment的用法示例。


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

示例1: parseTextAlignment

private static Alignment parseTextAlignment(String s) {
  switch (s) {
    case "start":
    case "left":
      return Alignment.ALIGN_NORMAL;
    case "center":
    case "middle":
      return Alignment.ALIGN_CENTER;
    case "end":
    case "right":
      return Alignment.ALIGN_OPPOSITE;
    default:
      Log.w(TAG, "Invalid alignment value: " + s);
      return null;
  }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:16,代码来源:WebvttCueParser.java

示例2: draw

@Override
public void draw(Canvas canvas) {
	canvas.save();

	mPaint.setColor(Color.TRANSPARENT);
	Rect rect = new Rect(0, 0, mDrawableWidth, mDrawableHeight);
	canvas.drawRect(rect, mPaint);

	mPaint.setColor(mTextBgColor);
	RectF rectf = new RectF(mMarginLeft, mMarginTop, mDrawableWidth
			- mMarginRight, mDrawableHeight - mMarginBottom);
	canvas.drawRoundRect(rectf, mRoundRectRadiusX, mRoundRectRadiusY,
			mPaint);

	canvas.translate(mMarginLeft + mPaddingLeft, mMarginTop + mPaddingTop);
	canvas.clipRect(0, 0, mContentWidth, mContentHeight);

	mPaint.setColor(mTextFgColor);
	StaticLayout layout = new StaticLayout(mContent, mPaint, mContentWidth,
			Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true);
	layout.draw(canvas);

	canvas.restore();
}
 
开发者ID:tangjiabing,项目名称:EmailTextArea,代码行数:24,代码来源:TextDrawable.java

示例3: measurePlainText

private void measurePlainText(int widthMeasureSpec, int heightMeasureSpec) {
    int paddingLeft = this.getPaddingLeft();
    int paddingRight = this.getPaddingRight();
    int paddingTop = this.getPaddingTop();
    int paddingBottom = this.getPaddingBottom();

    // max allowed width or height
    int sizeWidth = MeasureSpec.getSize(widthMeasureSpec) - paddingLeft - paddingRight;
    int sizeHeight = MeasureSpec.getSize(heightMeasureSpec) - paddingTop - paddingBottom;

    // mode
    int modeWidth = MeasureSpec.getMode(widthMeasureSpec);
    int modeHeight = MeasureSpec.getMode(heightMeasureSpec);

    // calculate text width and height
    mPaint.setTextSize(mTextSize);
    mStaticLayout = new StaticLayout(mTextString, mPaint, sizeWidth, Alignment.ALIGN_NORMAL, 1.0f, 0, false);

    // measured width and height
    int measuredWidth =
            modeWidth == MeasureSpec.EXACTLY ? sizeWidth : Math.min(sizeWidth,
                    (int) Math.ceil(Layout.getDesiredWidth(mTextString, mPaint)));
    int measuredHeight = modeHeight == MeasureSpec.EXACTLY ? sizeHeight : mStaticLayout.getHeight();

    setMeasuredDimension(measuredWidth + paddingLeft + paddingRight, measuredHeight + paddingTop + paddingBottom);
}
 
开发者ID:titanseason,项目名称:pinyin-text-view,代码行数:26,代码来源:PinyinTextView.java

示例4: getIntrinsicHeight

@Override
public int getIntrinsicHeight() {
	StaticLayout layout = new StaticLayout(mContent, mPaint, mContentWidth,
			Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true);
	int textHeight = layout.getHeight();
	int height = 0;
	if (textHeight + mPaddingTop + mPaddingBottom + mMarginTop
			+ mMarginBottom > mMaxHeight) {
		height = mMaxHeight;
		mContentHeight = height - mPaddingTop - mPaddingBottom - mMarginTop
				- mMarginBottom;
	} else {
		height = textHeight + mPaddingTop + mPaddingBottom + mMarginTop
				+ mMarginBottom;
		mContentHeight = textHeight;
	}
	return height;
}
 
开发者ID:tangjiabing,项目名称:EmailTextArea,代码行数:18,代码来源:TextDrawable.java

示例5: drawText

private static void drawText(Canvas canvas, int xStart, int yStart,
		int xWidth, int yHeigth, String textToDisplay,
		TextPaint paintToUse, float startTextSizeInPixels,
		float stepSizeForTextSizeSteps) {

	// Text view line spacing multiplier
	float mSpacingMult = 1.0f;
	// Text view additional line spacing
	float mSpacingAdd = 0.0f;
	StaticLayout l = null;
	do {
		paintToUse.setTextSize(startTextSizeInPixels);
		startTextSizeInPixels -= stepSizeForTextSizeSteps;
		l = new StaticLayout(textToDisplay, paintToUse, xWidth,
				Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true);
	} while (l.getHeight() > yHeigth);

	int textCenterX = xStart + (xWidth / 2);
	int textCenterY = (yHeigth - l.getHeight()) / 2;

	canvas.save();
	canvas.translate(textCenterX, textCenterY);
	l.draw(canvas);
	canvas.restore();
}
 
开发者ID:pnosalik,项目名称:AugmentedOxford,代码行数:25,代码来源:SimpleRatingBar.java

示例6: onTestSize

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public int onTestSize(int suggestedSize, RectF availableSPace) {
    mPaint.setTextSize(suggestedSize);
    String text = getText().toString();
    boolean singleline = getMaxLines() == 1;
    if (singleline) {
        mTextRect.bottom = mPaint.getFontSpacing();
        mTextRect.right = mPaint.measureText(text);
    } else {
        StaticLayout layout = new StaticLayout(text, mPaint,
                mWidthLimit, Alignment.ALIGN_NORMAL, mSpacingMult,
                mSpacingAdd, true);
        // return early if we have more lines
        if (getMaxLines() != NO_LINE_LIMIT
                && layout.getLineCount() > getMaxLines()) {
            return 1;
        }
        mTextRect.bottom = layout.getHeight();
        int maxWidth = -1;
        for (int i = 0; i < layout.getLineCount(); i++) {
            if (maxWidth < layout.getLineWidth(i)) {
                maxWidth = (int) layout.getLineWidth(i);
            }
        }
        mTextRect.right = maxWidth;
    }

    mTextRect.offsetTo(0, 0);
    if (availableSPace.contains(mTextRect)) {
        // may be too small, don't worry we will find the best match
        return -1;
    } else {
        // too big
        return 1;
    }
}
 
开发者ID:chashmeetsingh,项目名称:TrackIt-Android,代码行数:37,代码来源:AutoResizeTextView.java

示例7: getTextHeight

private int getTextHeight(CharSequence source, TextPaint paint, int width, float textSize) {
    // modified: make a copy of the original TextPaint object for measuring
    // (apparently the object gets modified while measuring, see also the
    // docs for TextView.getPaint() (which states to access it read-only)
    TextPaint paintCopy = new TextPaint(paint);
    // Update the text paint object
    paintCopy.setTextSize(textSize);
    // Measure using a static layout
    StaticLayout layout = new StaticLayout(source, paintCopy, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true);
    return layout.getHeight();
}
 
开发者ID:kingblaubart,项目名称:quidditchtimekeeper,代码行数:11,代码来源:AutoResizeTextView.java

示例8: draw

@Override public void draw(@NonNull Canvas canvas) {
    Paint paint = new Paint();
    paint.setColor(textColor);
    paint.setStyle(Style.STROKE);

    int numberOfColumns = tableRow.size();

    if (numberOfColumns == 0) {
        return;
    }

    int columnWidth = tableWidth / numberOfColumns;

    int offset;

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

        offset = i * columnWidth;

        if (paintBorder) {
            // The rect is open at the bottom, so there's a single line
            // between rows.
            canvas.drawRect(offset, 0, offset + columnWidth, rowHeight, paint);
        }

        StaticLayout layout = new StaticLayout(tableRow.get(i),
                getTextPaint(), (columnWidth - 2 * PADDING),
                Alignment.ALIGN_NORMAL, 1.5f, 0.5f, true);

        canvas.translate(offset + PADDING, 0);
        layout.draw(canvas);
        canvas.translate(-1 * (offset + PADDING), 0);

    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:35,代码来源:TableHandler.java

示例9: onMeasure

@SuppressLint({"DrawAllocation"})
protected void onMeasure(int i, int i2) {
    try {
        super.onMeasure(i, i2);
    } catch (Throwable e) {
        FirebaseCrash.report(e);
        setMeasuredDimension(MeasureSpec.getSize(i), AndroidUtilities.dp(51.0f));
        FileLog.e("tmessages", e);
    }
    this.f399b = null;
    if (this.f398a != null && this.f398a.length() > 0) {
        CharSequence text = getText();
        if (text.length() > 1 && text.charAt(0) == '@') {
            int indexOf = TextUtils.indexOf(text, ' ');
            if (indexOf != -1) {
                TextPaint paint = getPaint();
                int ceil = (int) Math.ceil((double) paint.measureText(text, 0, indexOf + 1));
                int measuredWidth = (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight();
                this.f400c = text.subSequence(0, indexOf + 1).length();
                CharSequence ellipsize = TextUtils.ellipsize(this.f398a, paint, (float) (measuredWidth - ceil), TruncateAt.END);
                this.f401d = ceil;
                try {
                    this.f399b = new StaticLayout(ellipsize, getPaint(), measuredWidth - ceil, Alignment.ALIGN_NORMAL, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT, 0.0f, false);
                    if (this.f399b.getLineCount() > 0) {
                        this.f401d = (int) (((float) this.f401d) + (-this.f399b.getLineLeft(0)));
                    }
                    this.f402e = ((getMeasuredHeight() - this.f399b.getLineBottom(0)) / 2) + AndroidUtilities.dp(0.5f);
                } catch (Throwable e2) {
                    FirebaseCrash.report(e2);
                    FileLog.e("tmessages", e2);
                }
            }
        }
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:35,代码来源:EditTextCaption.java

示例10: makeLayout

private Layout makeLayout(CharSequence text) {
    CharSequence transformed;
    if (this.mSwitchTransformationMethod != null) {
        transformed = this.mSwitchTransformationMethod.getTransformation(text, this);
    } else {
        transformed = text;
    }
    return new StaticLayout(transformed, this.mTextPaint, transformed != null ? (int) Math.ceil((double) Layout.getDesiredWidth(transformed, this.mTextPaint)) : 0, Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:SwitchCompat.java

示例11: fitsParent

private static boolean fitsParent(final String text, final TextPaint paint, final float parentW, final float parentH, float textSize) {
    paint.setTextSize(textSize);
    Rect bounds = new Rect();
    paint.getTextBounds(text, 0, text.length(), bounds);
    StaticLayout textLayout = new StaticLayout(text, paint, bounds.width(), Alignment.ALIGN_NORMAL, 0.0f, 0.0f, false);
    return (textLayout.getHeight() <= parentH && textLayout.getWidth() <= parentW) &&
            (Math.abs(parentH - textLayout.getHeight()) >= 0 &&
                    Math.abs(parentW - textLayout.getWidth()) >= 0);
}
 
开发者ID:fleksy,项目名称:TextDrawable,代码行数:9,代码来源:TextDrawable.java

示例12: getTextHeight

private int getTextHeight(CharSequence source, TextPaint paint, int width, float textSize) {
    // modified: make a copy of the original TextPaint object for measuring
    // (apparently the object gets modified while measuring, see also the
    // docs for TextView.getPaint() (which states to access it read-only)
    TextPaint paintCopy = new TextPaint(paint);
    // Update the text paint object
    paintCopy.setTextSize(textSize );
    // Measure using a static layout
    StaticLayout layout = new StaticLayout(source, paintCopy, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true);
    return layout.getHeight();
}
 
开发者ID:WowWeeLabs,项目名称:RoboSapien-Blue-RoboRaptor-Blue-Android-SDK,代码行数:11,代码来源:DimmableButton.java

示例13: getTextLineCount

private int getTextLineCount(CharSequence source, TextPaint paint, int widthPx, float textSize) {
    paint.setTextSize(textSize);
    StaticLayout layout = new StaticLayout(source, paint, widthPx, Alignment.ALIGN_NORMAL,
        mSpacingMult,
        mSpacingAdd, true);
    layout.draw(TEXT_RESIZE_CANVAS);

    return layout.getLineCount();
}
 
开发者ID:CaMnter,项目名称:AndroidLife,代码行数:9,代码来源:AutoResizeTextView.java

示例14: getTextHeight

private int getTextHeight(CharSequence source, TextPaint paint, int width, float textSize) {
    // Update the text paint object
    paint.setTextSize(textSize);
    // Draw using a static layout
    StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, false);
    layout.draw(sTextResizeCanvas);
    return layout.getHeight();
}
 
开发者ID:componavt,项目名称:wikokit,代码行数:8,代码来源:AutoResizeTextView.java

示例15: onTestSize

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public int onTestSize(int suggestedSize, RectF availableSPace) {
	mPaint.setTextSize(suggestedSize);
	String text = getText().toString();
	boolean singleline = getMaxLines() == 1;
	if (singleline) {
		mTextRect.bottom = mPaint.getFontSpacing();
		mTextRect.right = mPaint.measureText(text);
	} else {
		StaticLayout layout = new StaticLayout(text, mPaint,
				mWidthLimit, Alignment.ALIGN_NORMAL, mSpacingMult,
				mSpacingAdd, true);
		// return early if we have more lines
		if (getMaxLines() != NO_LINE_LIMIT
				&& layout.getLineCount() > getMaxLines()) {
			return 1;
		}
		mTextRect.bottom = layout.getHeight();
		int maxWidth = -1;
		for (int i = 0; i < layout.getLineCount(); i++) {
			if (maxWidth < layout.getLineWidth(i)) {
				maxWidth = (int) layout.getLineWidth(i);
			}
		}
		mTextRect.right = maxWidth;
	}

	mTextRect.offsetTo(0, 0);
	if (availableSPace.contains(mTextRect)) {
		// may be too small, don't worry we will find the best match
		return -1;
	} else {
		// too big
		return 1;
	}
}
 
开发者ID:Ocypode,项目名称:ocypode,代码行数:37,代码来源:AutoResizeTextView.java


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