Procházet zdrojové kódy

Add basic splash screen example (#1186)

Elliot Hesp před 7 roky
rodič
revize
1cb44fe699
1 změnil soubory, kde provedl 31 přidání a 1 odebrání
  1. 31
    1
      docs/android-specific-use-cases.md

+ 31
- 1
docs/android-specific-use-cases.md Zobrazit soubor

@@ -68,7 +68,37 @@ public class MyApplication extends NavigationApplication {
68 68
 `MainActivity` extends `SplashActiviy` which is used to start the react context. Once react is up and running `MainActivity` is **stopped** and another activity takes over to run our app: `NavigationActivity`. Due to this design, there's usually no point in overriding lifecycle callbacks in `MainActivity`.
69 69
 
70 70
 ## Splash screen
71
-Override `getSplashLayout` or `createSplashLayout` in `MainActivity` to provide a splash layout which will be displayed while Js context initialises.
71
+Override `getSplashLayout` or `createSplashLayout` in `MainActivity` to provide a splash layout which will be displayed while Js context initialises, for example:
72
+
73
+```java
74
+import android.widget.LinearLayout;
75
+import android.graphics.Color;
76
+import android.widget.TextView;
77
+import android.view.Gravity;
78
+import android.util.TypedValue;
79
+
80
+import com.reactnativenavigation.controllers.SplashActivity;
81
+
82
+public class MainActivity extends SplashActivity {
83
+
84
+    @Override
85
+    public LinearLayout createSplashLayout() {
86
+        LinearLayout view = new LinearLayout(this);
87
+        TextView textView = new TextView(this);
88
+
89
+        view.setBackgroundColor(Color.parseColor("#607D8B"));
90
+        view.setGravity(Gravity.CENTER);
91
+
92
+        textView.setTextColor(Color.parseColor("#FFFFFF"));
93
+        textView.setText("React Native Navigation");
94
+        textView.setGravity(Gravity.CENTER);
95
+        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 40);
96
+
97
+        view.addView(textView);
98
+        return view;
99
+    }
100
+}
101
+```
72 102
 
73 103
 ## Snackbar
74 104
 Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen. Snackbars appear above all other elements on screen and only one can be displayed at a time.