From 51a07ade2897953111fc11daebd74567799fe66a Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Thu, 25 Sep 2014 20:56:27 +0200 Subject: [PATCH] Fixed broken layout for buttons with configured color in messagebox on Android. --- android-project/src/org/libsdl/app/SDLActivity.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index 950cd4370..c3e0a8782 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -24,6 +24,7 @@ import android.os.*; 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 @@ public class SDLActivity extends Activity { // 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