Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android override Theme.Dialog windowTitleStyle property for AlertDialog.Builder

I'm using AlertDialog.Builder like this:

ContextThemeWrapper cw = new ContextThemeWrapper(context, R.style.AlertDialogTheme);
AlertDialog.Builder builder = new AlertDialog.Builder(cw);

This is my custom AlertDialogTheme style:

<style name="AlertDialogTheme" parent="@android:Theme.Dialog">
    <item name="android:textSize">15sp</item>
    <item name="android:windowTitleStyle">@style/custom_style</item>
</style>    

The textSize attribute works fine for the list of items I put in the builder with builder.setItems(), but it doesn't work on the title, so I've tried to override the windowTitleStyle attribute, but it doesn't work.

Is it even possible or am I doing something wrong?

like image 334
solnaranu Avatar asked Nov 20 '25 14:11

solnaranu


1 Answers

I'm having similar issues, and I've done just what you have. One thing to note is that windowTitleStyle isn't used in the dialog title before API 14. Before that it was textAppearanceMedium. And in the default (pre-holo) dialog it is textAppearanceLarge.

Unfortunately, I'm setting all three of these to my custom style and testing in KK, but it still doesn't update the color as I'm expecting.

like image 87
Dave Morgan Avatar answered Nov 22 '25 03:11

Dave Morgan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!