
On Android 4 this works fine but on 2.3.3 I’m getting (instead of a total dark gray background) a light grey horizontal stripe behind the top of the OK button. Any ideas what might be causing this? Thanks!
private void showResult(final String message) {
final Context context = this;
Runnable run = new Runnable() {
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(message)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
};
this.runOnUiThread(run);
}
I have:
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
and in values/styles.xml
<resources>
<style name="AppTheme" parent="android:Theme.Light" />
</resources>
I am not sure whether you’re looking for a dark gray background on everything, or just for consistency.
Have you tried changing the Theme of the
AlertDialog.Builder? In API11+, there’s a second constructor you can use which takes an integer argument to set the theme. Perhaps setting it back to the "traditional" theme would get it to look the same across versions?If that doesn’t work for you, you can use
AlertDialog.Builder().setView(View)to be able to further specify the attributes of each of the items in the dialog (so you could potentially putButtons in theViewyou pass, and set the background of the buttons to gray).