當前位置: 首頁>>代碼示例>>Java>>正文


Java Alignment類代碼示例

本文整理匯總了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;
  }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:17,代碼來源:WebvttCueParser.java

示例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);
    }
}
 
開發者ID:xieyangxuejun,項目名稱:CommentView,代碼行數:27,代碼來源:CanvasTextArea.java

示例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;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:18,代碼來源:Cue.java

示例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;
}
 
開發者ID:novoda,項目名稱:no-player,代碼行數:27,代碼來源:NoPlayerCue.java

示例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);
}
 
開發者ID:asifkhan11,項目名稱:ExoPlayer-Demo,代碼行數:19,代碼來源:WebvttParserTest.java

示例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);
}
 
開發者ID:titanseason,項目名稱:pinyin-text-view,代碼行數:27,代碼來源:PinyinTextView.java

示例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);
}
 
開發者ID:Ronak-LM,項目名稱:memoir,代碼行數:27,代碼來源:AlignmentEffect.java

示例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);
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:24,代碼來源:WebvttDecoderTest.java

示例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);
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:19,代碼來源:WebvttDecoderTest.java

示例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();
}
 
開發者ID:tangjiabing,項目名稱:EmailTextArea,代碼行數:25,代碼來源:TextDrawable.java

示例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;
}
 
開發者ID:tangjiabing,項目名稱:EmailTextArea,代碼行數:19,代碼來源:TextDrawable.java

示例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;
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:21,代碼來源:SwitchCompat.java

示例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;
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:21,代碼來源:hnr.java

示例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);
}
 
開發者ID:y20k,項目名稱:transistor,代碼行數:24,代碼來源:WebvttDecoderTest.java

示例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);
	}
}
 
開發者ID:gzncland,項目名稱:colorfullife,代碼行數:26,代碼來源:WindowSelectOppoment.java


注:本文中的android.text.Layout.Alignment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。