简体   繁体   中英

How to change the title background color of the dialog?

How do I change title's background in this dialog ["Lesson Editor"]?

As you can see,the theme of my application is dark and in the title's background in the main activities are dark as i want, but somehow the dialog isn't. Help me please!!

Here is the screenshot of my dialog:

在此处输入图片说明

Recently I used it for my implementation, so here is my code.

You can do that by creating a new style in the styles.xml file:

<style name="question_dialog" parent="@android:style/Theme.Holo.Dialog">
    <item name="android:windowTitleStyle">@style/question_dialog_title</item>
</style>

<style name="question_dialog_title" parent="android:Widget.TextView">
    <item name="android:background">#5cc5cc</item>
    <item name="android:textSize">21sp</item>
    <item name="android:textColor">#ffffff</item>
</style>

and then, when you create your Dialog object, you wanna use this constructor:

answeringDialog = new Dialog(this, R.style.question_dialog);

the output is:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM