类android.text.Layout.Alignment源码实例Demo

下面列出了怎么用android.text.Layout.Alignment的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: MediaSDK   文件: WebvttCue.java
@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;
  }
}
 
源代码2 项目: MediaSDK   文件: Cue.java
/**
 * 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);
}
 
源代码3 项目: TelePlus-Android   文件: WebvttCueParser.java
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;
  }
}
 
源代码4 项目: TelePlus-Android   文件: Cue.java
/**
 * 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);
}
 
源代码5 项目: TelePlus-Android   文件: WebvttCueParser.java
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;
  }
}
 
源代码6 项目: TelePlus-Android   文件: Cue.java
/**
 * 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);
}
 
源代码7 项目: litho   文件: TextSpec.java
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;
}
 
源代码8 项目: Telegram-FOSS   文件: Cue.java
/**
 * 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);
}
 
源代码9 项目: Telegram   文件: WebvttCueParser.java
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;
  }
}
 
源代码10 项目: no-player   文件: NoPlayerCue.java
@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;
}
 
源代码11 项目: no-player   文件: WebvttCueParser.java
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;
    }
}
 
源代码12 项目: memoir   文件: AlignmentEffect.java
@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);
}
 
源代码13 项目: memoir   文件: AlignmentEffect.java
@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);
}
 
源代码14 项目: Telegram-FOSS   文件: WebvttCueParser.java
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;
  }
}
 
源代码15 项目: MediaSDK   文件: WebvttCue.java
private WebvttCue(
    long startTime,
    long endTime,
    CharSequence text,
    @Nullable 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;
}
 
源代码16 项目: MediaSDK   文件: Cue.java
/**
 * 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);
}
 
源代码17 项目: TelePlus-Android   文件: WebvttCue.java
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;
}
 
源代码18 项目: TelePlus-Android   文件: Cue.java
/**
 * 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);
}
 
源代码19 项目: TelePlus-Android   文件: Cue.java
/**
 * 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);
}
 
源代码20 项目: Telegram   文件: WebvttCue.java
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;
}
 
源代码21 项目: TelePlus-Android   文件: WebvttCue.java
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;
}
 
源代码22 项目: TelePlus-Android   文件: Cue.java
/**
 * 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);
}
 
源代码23 项目: TelePlus-Android   文件: Cue.java
/**
 * 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);
}
 
源代码24 项目: TelePlus-Android   文件: Cue.java
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;
}
 
源代码25 项目: mvvm-template   文件: TableHandler.java
@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);

    }
}
 
源代码26 项目: Telegram-FOSS   文件: Cue.java
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;
}
 
源代码27 项目: Telegram-FOSS   文件: Cue.java
/**
 * 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);
}
 
源代码28 项目: K-Sonic   文件: WebvttCue.java
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;
}
 
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();
}
 
源代码30 项目: K-Sonic   文件: Cue.java
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;
}
 
 类所在包
 同包方法