Fixed broken layout for buttons with configured color in messagebox on Android.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Thu, 25 Sep 2014 20:56:27 +0200
changeset 9152 9ecf775ead1b
parent 9151 4d9654187aed
child 9153 b0a76d1f4a56
Fixed broken layout for buttons with configured color in messagebox on Android.
android-project/src/org/libsdl/app/SDLActivity.java
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Wed Sep 24 23:46:46 2014 +0200
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Thu Sep 25 20:56:27 2014 +0200
@@ -24,6 +24,7 @@
 import android.util.Log;
 import android.util.SparseArray;
 import android.graphics.*;
+import android.graphics.drawable.Drawable;
 import android.media.*;
 import android.hardware.*;
 
@@ -748,7 +749,14 @@
                 // TODO set color for border of messagebox button
             }
             if (buttonBackgroundColor != Color.TRANSPARENT) {
-                button.setBackgroundColor(buttonBackgroundColor);
+                Drawable drawable = button.getBackground();
+                if (drawable == null) {
+                    // setting the color this way removes the style
+                    button.setBackgroundColor(buttonBackgroundColor);
+                } else {
+                    // setting the color this way keeps the style (gradient, padding, etc.)
+                    drawable.setColorFilter(buttonBackgroundColor, PorterDuff.Mode.MULTIPLY);
+                }
             }
             if (buttonSelectedColor != Color.TRANSPARENT) {
                 // TODO set color for selected messagebox button