diff --git a/android/src/main/java/com/mehcode/reactnative/splashscreen/SplashScreen.java b/android/src/main/java/com/mehcode/reactnative/splashscreen/SplashScreen.java
index 9b6cd5d..900dd7e 100644
--- a/android/src/main/java/com/mehcode/reactnative/splashscreen/SplashScreen.java
+++ b/android/src/main/java/com/mehcode/reactnative/splashscreen/SplashScreen.java
@@ -2,6 +2,7 @@
import android.app.Activity;
import android.app.Dialog;
+import android.content.res.TypedArray;
import android.graphics.Color;
import com.facebook.react.ReactActivity;
@@ -35,6 +36,10 @@ public void run() {
mSplashDialog.show();
}
+ // Use color of "splashBackgroundColor" attribute in user theme, fallback to white if not set
+ TypedArray styledAttributes = activity.getTheme().obtainStyledAttributes(R.styleable.RNSplashScreen_Styleable);
+ final int backgroundColor = styledAttributes.getColor(R.styleable.RNSplashScreen_Styleable_splashBackgroundColor, Color.WHITE);
+
// If given an instance manager; ensure that we transition to the stage-2
// splash screen
// TODO: If you think of a better way to do this; PR please
@@ -43,14 +48,14 @@ public void run() {
// background state and we will not get the context created event
ReactContext ctx = instanceManager.getCurrentReactContext();
if (ctx != null) {
- activity.getWindow().getDecorView().setBackgroundColor(Color.WHITE);
+ activity.getWindow().getDecorView().setBackgroundColor(backgroundColor);
} else {
// Else; wait until react is initialized before we release the native splash
instanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext context) {
// Hide the native splash screen
- activity.getWindow().getDecorView().setBackgroundColor(Color.WHITE);
+ activity.getWindow().getDecorView().setBackgroundColor(backgroundColor);
}
});
}
diff --git a/android/src/main/res/values/attr.xml b/android/src/main/res/values/attr.xml
new file mode 100644
index 0000000..63b09f2
--- /dev/null
+++ b/android/src/main/res/values/attr.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/docs/android.md b/docs/android.md
index 23839ef..8df51da 100644
--- a/docs/android.md
+++ b/docs/android.md
@@ -44,3 +44,12 @@
// [...]
}
```
+
+5. (OPTIONAL) In `android/app/src/main/res/values/styles.xml`: Add `splashBackgroundColor` attribute with a color you want to see under keyboard while open/close animation is happening (defaults to white).
+
+ ```xml
+
+ ```