Java Code Examples for android.view.View#TEXT_ALIGNMENT_GRAVITY

The following examples show how to use android.view.View#TEXT_ALIGNMENT_GRAVITY . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
private static String nameForAlignment(int alignment) {
  switch (alignment) {
    case View.TEXT_ALIGNMENT_CENTER:
      return "TEXT_ALIGNMENT_CENTER";
    case View.TEXT_ALIGNMENT_GRAVITY:
      return "TEXT_ALIGNMENT_GRAVITY";
    case View.TEXT_ALIGNMENT_INHERIT:
      return "TEXT_ALIGNMENT_INHERIT";
    case View.TEXT_ALIGNMENT_TEXT_END:
      return "TEXT_ALIGNMENT_TEXT_END";
    case View.TEXT_ALIGNMENT_TEXT_START:
      return "TEXT_ALIGNMENT_TEXT_START";
    case View.TEXT_ALIGNMENT_VIEW_END:
      return "TEXT_ALIGNMENT_VIEW_END";
    case View.TEXT_ALIGNMENT_VIEW_START:
      return "TEXT_ALIGNMENT_VIEW_START";
    default:
      return "Unknown value";
  }
}
 
Example 2
Source Project: litho   File: TextStylesHelper.java    License: Apache License 2.0 5 votes vote down vote up
private static TextAlignment getTextAlignment(int viewTextAlignment, int gravity) {
  final TextAlignment alignment;
  switch (viewTextAlignment) {
    case View.TEXT_ALIGNMENT_TEXT_START:
      alignment = TextAlignment.TEXT_START;
      break;
    case View.TEXT_ALIGNMENT_TEXT_END:
      alignment = TextAlignment.TEXT_END;
      break;
    case View.TEXT_ALIGNMENT_CENTER:
      alignment = TextAlignment.CENTER;
      break;
    case View.TEXT_ALIGNMENT_VIEW_START:
      alignment = TextAlignment.LAYOUT_START;
      break;
    case View.TEXT_ALIGNMENT_VIEW_END:
      alignment = TextAlignment.LAYOUT_END;
      break;
    case View.TEXT_ALIGNMENT_INHERIT: // unsupported, default to gravity
    case View.TEXT_ALIGNMENT_GRAVITY:
      alignment = getTextAlignment(gravity);
      break;
    default:
      alignment = textAlignmentDefault;
      break;
  }
  return alignment;
}
 
Example 3
Source Project: litho   File: EditTextSpec.java    License: Apache License 2.0 5 votes vote down vote up
private static Layout.Alignment getAlignment(int viewTextAlignment, int gravity) {
  final Layout.Alignment alignment;
  // This was copied from TextSpec for handling text alignment
  switch (viewTextAlignment) {
    case View.TEXT_ALIGNMENT_GRAVITY:
      alignment = getAlignment(gravity);
      break;
    case View.TEXT_ALIGNMENT_TEXT_START:
      alignment = ALIGN_NORMAL;
      break;
    case View.TEXT_ALIGNMENT_TEXT_END:
      alignment = ALIGN_OPPOSITE;
      break;
    case View.TEXT_ALIGNMENT_CENTER:
      alignment = ALIGN_CENTER;
      break;
    case View.TEXT_ALIGNMENT_VIEW_START: // unsupported, default to normal
      alignment = ALIGN_NORMAL;
      break;
    case View.TEXT_ALIGNMENT_VIEW_END: // unsupported, default to opposite
      alignment = ALIGN_OPPOSITE;
      break;
    case View.TEXT_ALIGNMENT_INHERIT: // unsupported, default to gravity
      alignment = getAlignment(gravity);
      break;
    default:
      alignment = textAlignment;
      break;
  }
  return alignment;
}