I am creating a custom dialog and I want to know how to change the background of the title bar.
I've tried two approaches:
1 - I've tried the AlertDialog.Builder method 'setCustomTitle'. I created a simple layout view comprising of a textview with layout width and height 'match_parent' and background color. When I run the app, only the top half of the title bar is showing the background color. The bottom half is still showing the default theme background color. Does anyone know why?
2 - I've created my own dialog theme. Ive created a style with parent inheritance to '@android:style/Theme.Holo.Light.Dialog'. I've then passed that in the AlertDialog.Builder constructor - new AlertDialog.Builder(this, R.style.test_dialog). It seems good but somehow the dialog is wrapped within a dialog. A square box is surrounding the dialog. Does anyone know why?
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>
And you can instantiate dialog:
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.