Skip to content
Snippets Groups Projects
Commit a262144d authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Add ViewCompatUtils.setElevation

Bug: 16210054
Change-Id: I632158951a60ab527246410caefd9fbe471dd859
parent 689064d0
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,9 @@ public final class ViewCompatUtils {
private static final Method METHOD_setPaddingRelative = CompatUtils.getMethod(
View.class, "setPaddingRelative",
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);
private ViewCompatUtils() {
// This utility class is not publicly instantiable.
......@@ -51,4 +54,11 @@ public final class ViewCompatUtils {
}
CompatUtils.invoke(view, null, METHOD_setPaddingRelative, start, top, end, bottom);
}
public static void setElevation(final View view, final float elevation) {
if (METHOD_setElevation == null) {
return;
}
CompatUtils.invoke(view, null, METHOD_setElevation, elevation);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment