Skip to content

Commit 5ac848c

Browse files
janicduplessisfacebook-github-bot-7
authored andcommitted
Allow setting elevation on any type of View
Summary: Moved setElevation from ReactViewManager to BaseViewManager. This allows setting elevation on any type of view such as Toolbar for exemple. Closes facebook/react-native#5292 Reviewed By: svcscm Differential Revision: D2837415 Pulled By: androidtrunkagent fb-gh-sync-id: a5aa7abd95b99303d312cd9c2414539335540925
1 parent c9f274c commit 5ac848c

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
2626
private static final String PROP_DECOMPOSED_MATRIX_TRANSLATE_X = "translateX";
2727
private static final String PROP_DECOMPOSED_MATRIX_TRANSLATE_Y = "translateY";
2828
private static final String PROP_OPACITY = "opacity";
29+
private static final String PROP_ELEVATION = "elevation";
2930
private static final String PROP_RENDER_TO_HARDWARE_TEXTURE = "renderToHardwareTextureAndroid";
3031
private static final String PROP_ACCESSIBILITY_LABEL = "accessibilityLabel";
3132
private static final String PROP_ACCESSIBILITY_COMPONENT_TYPE = "accessibilityComponentType";
@@ -63,6 +64,14 @@ public void setDecomposedMatrix(T view, ReadableMap decomposedMatrix) {
6364
public void setOpacity(T view, float opacity) {
6465
view.setAlpha(opacity);
6566
}
67+
68+
@ReactProp(name = PROP_ELEVATION)
69+
public void setElevation(T view, float elevation) {
70+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
71+
view.setElevation(PixelUtil.toPixelFromDIP(elevation));
72+
}
73+
// Do nothing on API < 21
74+
}
6675

6776
@ReactProp(name = PROP_RENDER_TO_HARDWARE_TEXTURE)
6877
public void setRenderToHardwareTexture(T view, boolean useHWTexture) {

ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ public void setBorderStyle(ReactViewGroup view, @Nullable String borderStyle) {
6161
view.setBorderStyle(borderStyle);
6262
}
6363

64-
@ReactProp(name = "elevation")
65-
public void setElevation(ReactViewGroup view, float elevation) {
66-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
67-
view.setElevation(PixelUtil.toPixelFromDIP(elevation));
68-
}
69-
// Do nothing on API < 21
70-
}
71-
7264
@ReactProp(name = "pointerEvents")
7365
public void setPointerEvents(ReactViewGroup view, @Nullable String pointerEventsStr) {
7466
if (pointerEventsStr != null) {

0 commit comments

Comments
 (0)