本文整理汇总了Java中android.text.Layout.Alignment类的典型用法代码示例。如果您正苦于以下问题:Java Alignment类的具体用法?Java Alignment怎么用?Java Alignment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Alignment类属于android.text.Layout包,在下文中一共展示了Alignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseTextAlignment
import android.text.Layout.Alignment; //导入依赖的package包/类
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;
}
}
示例2: makeSingleLayout
import android.text.Layout.Alignment; //导入依赖的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);
}
}
示例3: Cue
import android.text.Layout.Alignment; //导入依赖的package包/类
private Cue(CharSequence text, Alignment textAlignment, Bitmap bitmap, float line,
@LineType int lineType, @AnchorType int lineAnchor, float position,
@AnchorType int positionAnchor, float size, float bitmapHeight, boolean windowColorSet,
int windowColor) {
this.text = text;
this.textAlignment = textAlignment;
this.bitmap = bitmap;
this.line = line;
this.lineType = lineType;
this.lineAnchor = lineAnchor;
this.position = position;
this.positionAnchor = positionAnchor;
this.size = size;
this.bitmapHeight = bitmapHeight;
this.windowColorSet = windowColorSet;
this.windowColor = windowColor;
}
示例4: NoPlayerCue
import android.text.Layout.Alignment; //导入依赖的package包/类
@SuppressWarnings({"checkstyle:ParameterNumber", "PMD.ExcessiveParameterList"}) // TODO group parameters into classes
public NoPlayerCue(CharSequence text,
Alignment textAlignment,
Bitmap bitmap,
float line,
int lineType,
int lineAnchor,
float position,
int positionAnchor,
float size,
float bitmapHeight,
boolean windowColorSet,
int windowColor) {
this.text = text;
this.textAlignment = textAlignment;
this.bitmap = bitmap;
this.line = line;
this.lineType = lineType;
this.lineAnchor = lineAnchor;
this.position = position;
this.positionAnchor = positionAnchor;
this.size = size;
this.bitmapHeight = bitmapHeight;
this.windowColorSet = windowColorSet;
this.windowColor = windowColor;
}
示例5: assertCue
import android.text.Layout.Alignment; //导入依赖的package包/类
private static void assertCue(WebvttSubtitle subtitle, int eventTimeIndex, long startTimeUs,
int endTimeUs, String text, Alignment textAlignment, float line, int lineType, int lineAnchor,
float position, int positionAnchor, float size) {
assertEquals(startTimeUs, subtitle.getEventTime(eventTimeIndex));
assertEquals(endTimeUs, subtitle.getEventTime(eventTimeIndex + 1));
List<Cue> cues = subtitle.getCues(subtitle.getEventTime(eventTimeIndex));
assertEquals(1, cues.size());
// Assert cue properties
Cue cue = cues.get(0);
assertEquals(text, cue.text.toString());
assertEquals(textAlignment, cue.textAlignment);
assertEquals(line, cue.line);
assertEquals(lineType, cue.lineType);
assertEquals(lineAnchor, cue.lineAnchor);
assertEquals(position, cue.position);
assertEquals(positionAnchor, cue.positionAnchor);
assertEquals(size, cue.size);
}
示例6: measurePlainText
import android.text.Layout.Alignment; //导入依赖的package包/类
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);
}
示例7: applyToSelection
import android.text.Layout.Alignment; //导入依赖的package包/类
@Override
public void applyToSelection(RTEditText editor, Selection selectedParagraphs, Layout.Alignment alignment) {
final Spannable str = editor.getText();
mSpans2Process.clear();
for (Paragraph paragraph : editor.getParagraphs()) {
// find existing AlignmentSpan and add them to mSpans2Process to be removed
List<RTSpan<Layout.Alignment>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
mSpans2Process.removeSpans(existingSpans, paragraph);
// if the paragraph is selected then we sure have an alignment
boolean hasExistingSpans = !existingSpans.isEmpty();
Alignment newAlignment = paragraph.isSelected(selectedParagraphs) ? alignment :
hasExistingSpans ? existingSpans.get(0).getValue() : null;
if (newAlignment != null) {
boolean isRTL = Helper.isRTL(str, paragraph.start(), paragraph.end());
AlignmentSpan alignmentSpan = new AlignmentSpan(newAlignment, isRTL);
mSpans2Process.addSpan(alignmentSpan, paragraph);
}
}
// add or remove spans
mSpans2Process.process(str);
}
示例8: testDecodeWithPositioning
import android.text.Layout.Alignment; //导入依赖的package包/类
public void testDecodeWithPositioning() throws IOException, SubtitleDecoderException {
WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_POSITIONING_FILE);
// Test event count.
assertEquals(12, subtitle.getEventTimeCount());
// Test cues.
assertCue(subtitle, 0, 0, 1234000, "This is the first subtitle.", Alignment.ALIGN_NORMAL,
Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, 0.1f, Cue.ANCHOR_TYPE_START, 0.35f);
assertCue(subtitle, 2, 2345000, 3456000, "This is the second subtitle.",
Alignment.ALIGN_OPPOSITE, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, Cue.DIMEN_UNSET,
Cue.TYPE_UNSET, 0.35f);
assertCue(subtitle, 4, 4000000, 5000000, "This is the third subtitle.",
Alignment.ALIGN_CENTER, 0.45f, Cue.LINE_TYPE_FRACTION, Cue.ANCHOR_TYPE_END, Cue.DIMEN_UNSET,
Cue.TYPE_UNSET, 0.35f);
assertCue(subtitle, 6, 6000000, 7000000, "This is the fourth subtitle.",
Alignment.ALIGN_CENTER, -10f, Cue.LINE_TYPE_NUMBER, Cue.TYPE_UNSET, Cue.DIMEN_UNSET,
Cue.TYPE_UNSET, Cue.DIMEN_UNSET);
assertCue(subtitle, 8, 7000000, 8000000, "This is the fifth subtitle.",
Alignment.ALIGN_OPPOSITE, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, 0.1f,
Cue.ANCHOR_TYPE_END, 0.1f);
assertCue(subtitle, 10, 10000000, 11000000, "This is the sixth subtitle.",
Alignment.ALIGN_CENTER, 0.45f, Cue.LINE_TYPE_FRACTION, Cue.ANCHOR_TYPE_END, Cue.DIMEN_UNSET,
Cue.TYPE_UNSET, 0.35f);
}
示例9: assertCue
import android.text.Layout.Alignment; //导入依赖的package包/类
private static void assertCue(WebvttSubtitle subtitle, int eventTimeIndex, long startTimeUs,
int endTimeUs, String text, Alignment textAlignment, float line, int lineType, int lineAnchor,
float position, int positionAnchor, float size) {
assertEquals(startTimeUs, subtitle.getEventTime(eventTimeIndex));
assertEquals(endTimeUs, subtitle.getEventTime(eventTimeIndex + 1));
List<Cue> cues = subtitle.getCues(subtitle.getEventTime(eventTimeIndex));
assertEquals(1, cues.size());
// Assert cue properties.
Cue cue = cues.get(0);
assertEquals(text, cue.text.toString());
assertEquals(textAlignment, cue.textAlignment);
assertEquals(line, cue.line);
assertEquals(lineType, cue.lineType);
assertEquals(lineAnchor, cue.lineAnchor);
assertEquals(position, cue.position);
assertEquals(positionAnchor, cue.positionAnchor);
assertEquals(size, cue.size);
}
示例10: draw
import android.text.Layout.Alignment; //导入依赖的package包/类
@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();
}
示例11: getIntrinsicHeight
import android.text.Layout.Alignment; //导入依赖的package包/类
@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;
}
示例12: makeLayout
import android.text.Layout.Alignment; //导入依赖的package包/类
private Layout makeLayout(CharSequence paramCharSequence)
{
CharSequence localCharSequence;
TextPaint localTextPaint;
if (this.mSwitchTransformationMethod != null)
{
localCharSequence = this.mSwitchTransformationMethod.getTransformation(paramCharSequence, this);
localTextPaint = this.mTextPaint;
if (localCharSequence == null) {
break label66;
}
}
label66:
for (int i = (int)Math.ceil(Layout.getDesiredWidth(localCharSequence, this.mTextPaint));; i = 0)
{
return new StaticLayout(localCharSequence, localTextPaint, i, Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true);
localCharSequence = paramCharSequence;
break;
}
}
示例13: a
import android.text.Layout.Alignment; //导入依赖的package包/类
protected final int a(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
int i1 = paramInt2 + this.H.aP;
this.h = new StaticLayout(getContext().getString(efj.Jg), efj.B(getContext(), ehr.bc), paramInt4, Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, false);
int i2 = i1 + this.h.getHeight() + this.H.aP;
this.q = i2;
int i3 = View.MeasureSpec.makeMeasureSpec(0, 0);
int i4 = View.MeasureSpec.makeMeasureSpec(this.P, 1073741824);
int i5 = d(false);
if (i5 == 0) {}
for (int i6 = i2 + a(paramInt4);; i6 = i2 + i5)
{
this.j.measure(i4, i3);
int i7 = i6 + this.j.getMeasuredHeight();
if (this.r == 0) {
this.r = i7;
}
return this.r;
}
}
示例14: testDecodeWithPositioning
import android.text.Layout.Alignment; //导入依赖的package包/类
public void testDecodeWithPositioning() throws IOException, SubtitleDecoderException {
WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_POSITIONING_FILE);
// Test event count.
assertEquals(12, subtitle.getEventTimeCount());
// Test cues.
assertCue(subtitle, 0, 0, 1234000, "This is the first subtitle.", Alignment.ALIGN_NORMAL,
Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, 0.1f, Cue.ANCHOR_TYPE_START, 0.35f);
assertCue(subtitle, 2, 2345000, 3456000, "This is the second subtitle.",
Alignment.ALIGN_OPPOSITE, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, Cue.DIMEN_UNSET,
Cue.TYPE_UNSET, 0.35f);
assertCue(subtitle, 4, 4000000, 5000000, "This is the third subtitle.",
Alignment.ALIGN_CENTER, 0.45f, Cue.LINE_TYPE_FRACTION, Cue.ANCHOR_TYPE_END, Cue.DIMEN_UNSET,
Cue.TYPE_UNSET, 0.35f);
assertCue(subtitle, 6, 6000000, 7000000, "This is the fourth subtitle.",
Alignment.ALIGN_CENTER, -11f, Cue.LINE_TYPE_NUMBER, Cue.TYPE_UNSET, Cue.DIMEN_UNSET,
Cue.TYPE_UNSET, Cue.DIMEN_UNSET);
assertCue(subtitle, 8, 7000000, 8000000, "This is the fifth subtitle.",
Alignment.ALIGN_OPPOSITE, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, 0.1f,
Cue.ANCHOR_TYPE_END, 0.1f);
assertCue(subtitle, 10, 10000000, 11000000, "This is the sixth subtitle.",
Alignment.ALIGN_CENTER, 0.45f, Cue.LINE_TYPE_FRACTION, Cue.ANCHOR_TYPE_END, Cue.DIMEN_UNSET,
Cue.TYPE_UNSET, 0.35f);
}
示例15: WindowSelectOppoment
import android.text.Layout.Alignment; //导入依赖的package包/类
public WindowSelectOppoment() {
bg = new Sprite2D(CacheManager.black.texture,
new RectF(0, 0, 1024, 512),
new RectF(0, 0, 1, 1)
);
bg.alpha = 0.8f;
btnCancel = new SpriteButton(CacheManager.getTextureById(R.drawable.ui_game), 608, 640, 144, 80);
btnCancel.setLocation(160,432);
for (int i = 0; i < 3; i++) {
SpriteButton btnOppoment = new SpriteButton(CacheManager.getTextureById(R.drawable.ui_game), 432, 640, 176, 208);
btnOppoment.setLocation(192 + i * 224, 160);
btnOppoments.add(btnOppoment);
Sprite2D spFace = CacheManager.getPlayerFaceById(0, 128, 128);
spFace.setLocation(217 + i * 224, 182.8f);
spFaces.add(spFace);
TextField txtName = new TextField("", 128, 32);
txtName.setColor(Color.BLACK);
txtName.setLocation(216 + i * 224, 314);
txtName.setAlign(Alignment.ALIGN_CENTER);
txtNames.add(txtName);
}
}