Skip to content

Commit ff04c69

Browse files
authored
Easy way to set the presplash background color
Easy way to set the presplash background color of Loading Screen. Edit this file: pythonforandroid/bootstraps/sdl2/build/templates/strings.tmpl.xml and set the background presplash color <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">{{ args.name }}</string> <string name="private_version">0.1</string> <string name="presplash_bkgcolor">#FF00FFFF</string> </resources> More information: https://developer.android.com/reference/android/graphics/Color.html Parse the color string, and return the corresponding color-int. If the string cannot be parsed, throws an IllegalArgumentException exception. Supported formats are: #RRGGBB #AARRGGBB or one of the following names: 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey', 'aqua', 'fuchsia', 'lime', 'maroon', 'navy', 'olive', 'purple', 'silver', 'teal'.
1 parent cce254f commit ff04c69

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.InputStream;
3131
import android.graphics.Bitmap;
3232
import android.graphics.BitmapFactory;
33+
import android.graphics.Color;
3334

3435
import org.libsdl.app.SDLActivity;
3536

@@ -356,6 +357,30 @@ protected void showLoadingScreen() {
356357

357358
mImageView = new ImageView(this);
358359
mImageView.setImageBitmap(bitmap);
360+
361+
/*
362+
* Edit this file: pythonforandroid/bootstraps/sdl2/build/templates/strings.tmpl.xml
363+
* and set the background presplash color
364+
* <?xml version="1.0" encoding="utf-8"?>
365+
* <resources>
366+
* <string name="app_name">{{ args.name }}</string>
367+
* <string name="private_version">0.1</string>
368+
* <string name="presplash_bkgcolor">#FF00FFFF</string>
369+
* </resources>
370+
* https://developer.android.com/reference/android/graphics/Color.html
371+
* Parse the color string, and return the corresponding color-int.
372+
* If the string cannot be parsed, throws an IllegalArgumentException exception.
373+
* Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
374+
* 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow',
375+
* 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey', 'aqua', 'fuchsia',
376+
* 'lime', 'maroon', 'navy', 'olive', 'purple', 'silver', 'teal'.
377+
*/
378+
String backgroundColor = resourceManager.getString("presplash_bkgcolor");
379+
if (backgroundColor != null) {
380+
try {
381+
mImageView.setBackgroundColor(Color.parseColor(backgroundColor));
382+
} catch (IllegalArgumentException e) {}
383+
}
359384
mImageView.setLayoutParams(new ViewGroup.LayoutParams(
360385
ViewGroup.LayoutParams.FILL_PARENT,
361386
ViewGroup.LayoutParams.FILL_PARENT));

0 commit comments

Comments
 (0)