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 91529ecf775ead1b
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
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Wed Sep 24 23:46:46 2014 +0200
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Thu Sep 25 20:56:27 2014 +0200
     1.3 @@ -24,6 +24,7 @@
     1.4  import android.util.Log;
     1.5  import android.util.SparseArray;
     1.6  import android.graphics.*;
     1.7 +import android.graphics.drawable.Drawable;
     1.8  import android.media.*;
     1.9  import android.hardware.*;
    1.10  
    1.11 @@ -748,7 +749,14 @@
    1.12                  // TODO set color for border of messagebox button
    1.13              }
    1.14              if (buttonBackgroundColor != Color.TRANSPARENT) {
    1.15 -                button.setBackgroundColor(buttonBackgroundColor);
    1.16 +                Drawable drawable = button.getBackground();
    1.17 +                if (drawable == null) {
    1.18 +                    // setting the color this way removes the style
    1.19 +                    button.setBackgroundColor(buttonBackgroundColor);
    1.20 +                } else {
    1.21 +                    // setting the color this way keeps the style (gradient, padding, etc.)
    1.22 +                    drawable.setColorFilter(buttonBackgroundColor, PorterDuff.Mode.MULTIPLY);
    1.23 +                }
    1.24              }
    1.25              if (buttonSelectedColor != Color.TRANSPARENT) {
    1.26                  // TODO set color for selected messagebox button