diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewManager.java index 13745a58ad6160..88046a62ca261f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewManager.java @@ -64,4 +64,12 @@ protected ARTSurfaceView createViewInstance(ThemedReactContext reactContext) { public void updateExtraData(ARTSurfaceView root, Object extraData) { root.setSurfaceTextureListener((ARTSurfaceViewShadowNode) extraData); } + + @Override + public void setBackgroundColor(ARTSurfaceView view, int backgroundColor) { + // As of Android N TextureView does not support calling setBackground on it. + // It will also throw an exception when target SDK is set to N or higher. + + // Setting the background color for this view is handled in the shadow node. + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewShadowNode.java index 538c0792fad093..e3c78600bd260b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewShadowNode.java @@ -24,6 +24,8 @@ import com.facebook.react.uimanager.LayoutShadowNode; import com.facebook.react.uimanager.UIViewOperationQueue; import com.facebook.react.uimanager.ReactShadowNode; +import com.facebook.react.uimanager.ViewProps; +import com.facebook.react.uimanager.annotations.ReactProp; /** * Shadow node for ART virtual tree root - ARTSurfaceView @@ -33,6 +35,14 @@ public class ARTSurfaceViewShadowNode extends LayoutShadowNode private @Nullable Surface mSurface; + private @Nullable Integer mBackgroundColor; + + @ReactProp(name = ViewProps.BACKGROUND_COLOR, customType = "Color") + public void setBackgroundColor(Integer color) { + mBackgroundColor = color; + markUpdated(); + } + @Override public boolean isVirtual() { return false; @@ -59,6 +69,9 @@ private void drawOutput() { try { Canvas canvas = mSurface.lockCanvas(null); canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); + if (mBackgroundColor != null) { + canvas.drawColor(mBackgroundColor); + } Paint paint = new Paint(); for (int i = 0; i < getChildCount(); i++) {