android.text.Layout.Alignment Java Examples
The following examples show how to use
android.text.Layout.Alignment.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebvttCue.java From MediaSDK with Apache License 2.0 | 6 votes |
@Nullable private static Alignment convertTextAlignment(@TextAlignment int textAlignment) { switch (textAlignment) { case TEXT_ALIGNMENT_START: case TEXT_ALIGNMENT_LEFT: return Alignment.ALIGN_NORMAL; case TEXT_ALIGNMENT_CENTER: return Alignment.ALIGN_CENTER; case TEXT_ALIGNMENT_END: case TEXT_ALIGNMENT_RIGHT: return Alignment.ALIGN_OPPOSITE; default: Log.w(TAG, "Unknown textAlignment: " + textAlignment); return null; } }
Example #2
Source File: WebvttCueParser.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
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; } }
Example #3
Source File: TextSpec.java From litho with Apache License 2.0 | 6 votes |
private static TextAlignment getTextAlignment( @Nullable Alignment alignment, @Nullable TextAlignment textAlignment) { if (textAlignment != null) { return textAlignment; } if (alignment != null) { switch (alignment) { default: case ALIGN_NORMAL: return TEXT_START; case ALIGN_OPPOSITE: return TEXT_END; case ALIGN_CENTER: return CENTER; } } return TEXT_START; }
Example #4
Source File: Cue.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. */ public Cue( CharSequence text, Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size) { this( text, textAlignment, line, lineType, lineAnchor, position, positionAnchor, size, /* windowColorSet= */ false, /* windowColor= */ Color.BLACK); }
Example #5
Source File: Cue.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. */ public Cue( CharSequence text, Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size) { this( text, textAlignment, line, lineType, lineAnchor, position, positionAnchor, size, /* windowColorSet= */ false, /* windowColor= */ Color.BLACK); }
Example #6
Source File: Cue.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. */ public Cue( CharSequence text, Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size) { this( text, textAlignment, line, lineType, lineAnchor, position, positionAnchor, size, /* windowColorSet= */ false, /* windowColor= */ Color.BLACK); }
Example #7
Source File: WebvttCueParser.java From Telegram with GNU General Public License v2.0 | 6 votes |
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; } }
Example #8
Source File: WebvttCueParser.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
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; } }
Example #9
Source File: NoPlayerCue.java From no-player with Apache License 2.0 | 6 votes |
@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; }
Example #10
Source File: WebvttCueParser.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
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; } }
Example #11
Source File: WebvttCueParser.java From no-player with Apache License 2.0 | 6 votes |
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; } }
Example #12
Source File: AlignmentEffect.java From memoir with Apache License 2.0 | 6 votes |
@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); }
Example #13
Source File: Cue.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. */ public Cue( CharSequence text, @Nullable Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size) { this( text, textAlignment, line, lineType, lineAnchor, position, positionAnchor, size, /* windowColorSet= */ false, /* windowColor= */ Color.BLACK); }
Example #14
Source File: AlignmentEffect.java From memoir with Apache License 2.0 | 6 votes |
@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); }
Example #15
Source File: Cue.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. * @param textSizeType See {@link #textSizeType}. * @param textSize See {@link #textSize}. */ public Cue( CharSequence text, @Nullable Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size, @TextSizeType int textSizeType, float textSize) { this( text, textAlignment, /* bitmap= */ null, line, lineType, lineAnchor, position, positionAnchor, textSizeType, textSize, size, /* bitmapHeight= */ DIMEN_UNSET, /* windowColorSet= */ false, /* windowColor= */ Color.BLACK); }
Example #16
Source File: Cue.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. * @param textSizeType See {@link #textSizeType}. * @param textSize See {@link #textSize}. */ public Cue( CharSequence text, Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size, @TextSizeType int textSizeType, float textSize) { this( text, textAlignment, /* bitmap= */ null, line, lineType, lineAnchor, position, positionAnchor, textSizeType, textSize, size, /* bitmapHeight= */ DIMEN_UNSET, /* windowColorSet= */ false, /* windowColor= */ Color.BLACK); }
Example #17
Source File: WebvttCue.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public WebvttCue(long startTime, long endTime, CharSequence text, Alignment textAlignment, float line, @Cue.LineType int lineType, @Cue.AnchorType int lineAnchor, float position, @Cue.AnchorType int positionAnchor, float width) { super(text, textAlignment, line, lineType, lineAnchor, position, positionAnchor, width); this.startTime = startTime; this.endTime = endTime; }
Example #18
Source File: Cue.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. * @param windowColorSet See {@link #windowColorSet}. * @param windowColor See {@link #windowColor}. */ public Cue( CharSequence text, Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size, boolean windowColorSet, int windowColor) { this( text, textAlignment, /* bitmap= */ null, line, lineType, lineAnchor, position, positionAnchor, /* textSizeType= */ TYPE_UNSET, /* textSize= */ DIMEN_UNSET, size, /* bitmapHeight= */ DIMEN_UNSET, windowColorSet, windowColor); }
Example #19
Source File: Cue.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. * @param textSizeType See {@link #textSizeType}. * @param textSize See {@link #textSize}. */ public Cue( CharSequence text, Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size, @TextSizeType int textSizeType, float textSize) { this( text, textAlignment, /* bitmap= */ null, line, lineType, lineAnchor, position, positionAnchor, textSizeType, textSize, size, /* bitmapHeight= */ DIMEN_UNSET, /* windowColorSet= */ false, /* windowColor= */ Color.BLACK); }
Example #20
Source File: WebvttCue.java From K-Sonic with MIT License | 5 votes |
public WebvttCue(long startTime, long endTime, CharSequence text, Alignment textAlignment, float line, @Cue.LineType int lineType, @Cue.AnchorType int lineAnchor, float position, @Cue.AnchorType int positionAnchor, float width) { super(text, textAlignment, line, lineType, lineAnchor, position, positionAnchor, width); this.startTime = startTime; this.endTime = endTime; }
Example #21
Source File: AutoResizeTextView.java From oneHookLibraryAndroid with Apache License 2.0 | 5 votes |
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(); }
Example #22
Source File: Cue.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. * @param windowColorSet See {@link #windowColorSet}. * @param windowColor See {@link #windowColor}. */ public Cue( CharSequence text, Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size, boolean windowColorSet, int windowColor) { this( text, textAlignment, /* bitmap= */ null, line, lineType, lineAnchor, position, positionAnchor, /* textSizeType= */ TYPE_UNSET, /* textSize= */ DIMEN_UNSET, size, /* bitmapHeight= */ DIMEN_UNSET, windowColorSet, windowColor); }
Example #23
Source File: Cue.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private Cue( CharSequence text, Alignment textAlignment, Bitmap bitmap, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, @TextSizeType int textSizeType, float textSize, 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; this.textSizeType = textSizeType; this.textSize = textSize; }
Example #24
Source File: StaticLayoutBuilderCompat.java From material-components-android with Apache License 2.0 | 5 votes |
private StaticLayoutBuilderCompat(CharSequence source, TextPaint paint, int width) { this.source = source; this.paint = paint; this.width = width; this.start = 0; this.end = source.length(); this.alignment = Alignment.ALIGN_NORMAL; this.maxLines = Integer.MAX_VALUE; this.includePad = true; this.ellipsize = null; }
Example #25
Source File: LyricView.java From RhymeMusic with Apache License 2.0 | 5 votes |
/** * 绘制文本,可自动换行 * @param text * @param canvas * @param y */ private void drawText(String text, Canvas canvas, float y) { int status = canvas.save(); canvas.translate(mWidth / 2, y); int w = mWidth - getPaddingLeft() - getPaddingRight(); StaticLayout layout = new StaticLayout(text, mPaint, w, Alignment.ALIGN_NORMAL, 1.0f, 0, false); layout.draw(canvas); canvas.restoreToCount(status); }
Example #26
Source File: TableHandler.java From mvvm-template with GNU General Public License v3.0 | 5 votes |
@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); } }
Example #27
Source File: Cue.java From K-Sonic with MIT License | 5 votes |
private Cue(CharSequence text, Alignment textAlignment, Bitmap bitmap, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size, 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.windowColorSet = windowColorSet; this.windowColor = windowColor; }
Example #28
Source File: AutoResizeTextView.java From juicessh-performancemonitor with Apache License 2.0 | 5 votes |
private int getTextHeight(CharSequence source, TextPaint paint, int width, float textSize) { // Update the text paint object paint.setTextSize(textSize); // Measure using a static layout StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true); return layout.getHeight(); }
Example #29
Source File: Cue.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private Cue( CharSequence text, Alignment textAlignment, Bitmap bitmap, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, @TextSizeType int textSizeType, float textSize, 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; this.textSizeType = textSizeType; this.textSize = textSize; }
Example #30
Source File: Cue.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Creates a text cue. * * @param text See {@link #text}. * @param textAlignment See {@link #textAlignment}. * @param line See {@link #line}. * @param lineType See {@link #lineType}. * @param lineAnchor See {@link #lineAnchor}. * @param position See {@link #position}. * @param positionAnchor See {@link #positionAnchor}. * @param size See {@link #size}. * @param windowColorSet See {@link #windowColorSet}. * @param windowColor See {@link #windowColor}. */ public Cue( CharSequence text, Alignment textAlignment, float line, @LineType int lineType, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size, boolean windowColorSet, int windowColor) { this( text, textAlignment, /* bitmap= */ null, line, lineType, lineAnchor, position, positionAnchor, /* textSizeType= */ TYPE_UNSET, /* textSize= */ DIMEN_UNSET, size, /* bitmapHeight= */ DIMEN_UNSET, windowColorSet, windowColor); }