diff options
Diffstat (limited to 'java/src/com/android/inputmethod/compat/ViewCompatUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/compat/ViewCompatUtils.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/compat/ViewCompatUtils.java b/java/src/com/android/inputmethod/compat/ViewCompatUtils.java index 767cc423d..0f00be133 100644 --- a/java/src/com/android/inputmethod/compat/ViewCompatUtils.java +++ b/java/src/com/android/inputmethod/compat/ViewCompatUtils.java @@ -30,7 +30,13 @@ public final class ViewCompatUtils { View.class, "getPaddingEnd"); private static final Method METHOD_setPaddingRelative = CompatUtils.getMethod( View.class, "setPaddingRelative", - Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE); + int.class, int.class, int.class, int.class); + // Note that View.setElevation(float) has been introduced in API level 21. + private static final Method METHOD_setElevation = CompatUtils.getMethod( + View.class, "setElevation", float.class); + // Note that View.setTextAlignment(int) has been introduced in API level 17. + private static final Method METHOD_setTextAlignment = CompatUtils.getMethod( + View.class, "setTextAlignment", int.class); private ViewCompatUtils() { // This utility class is not publicly instantiable. @@ -51,4 +57,21 @@ public final class ViewCompatUtils { } CompatUtils.invoke(view, null, METHOD_setPaddingRelative, start, top, end, bottom); } + + public static void setElevation(final View view, final float elevation) { + CompatUtils.invoke(view, null, METHOD_setElevation, elevation); + } + + // These TEXT_ALIGNMENT_* constants have been introduced in API 17. + public static final int TEXT_ALIGNMENT_INHERIT = 0; + public static final int TEXT_ALIGNMENT_GRAVITY = 1; + public static final int TEXT_ALIGNMENT_TEXT_START = 2; + public static final int TEXT_ALIGNMENT_TEXT_END = 3; + public static final int TEXT_ALIGNMENT_CENTER = 4; + public static final int TEXT_ALIGNMENT_VIEW_START = 5; + public static final int TEXT_ALIGNMENT_VIEW_END = 6; + + public static void setTextAlignment(final View view, final int textAlignment) { + CompatUtils.invoke(view, null, METHOD_setTextAlignment, textAlignment); + } } |