且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的 - 更改自定义对话框的标题背景

更新时间:2023-01-23 21:07:11

您可以创建一个样式一样,

You can create a style like,

<style name="cust_dialog" parent="@android:style/Theme.Dialog">
    <item name="android:windowTitleStyle">@style/dialog_title_style</item>
  </style>

<style name="dialog_title_style" parent="android:Widget.TextView">
    <item name="android:background">@android:color/black</item>
    <item name="android:padding">10dp</item>
</style>

和可以实例对话框:

Dialog dialog=new Dialog(this,R.style.cust_dialog);
dialog.setContentView(R.layout.fragment_features_dialog);
dialog.setTitle(R.string.features);

现在的对话框显示了黑色的标题背景颜色。

Now the dialog shows up with black title background color.