1

I have the following style that is supposed to display the Title of the Dialog box

<style name="CustomDialog" parent="@style/Theme.AppCompat.Light.Dialog">
    <item name="android:windowNoTitle">false</item>
</style>

However, the dialog does not display the title.The dialog looks like the image below Dialog With no title. I have also include the code that I use to initialize the view

void initView(int maxLength)
{
    setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);

    getDialog().setTitle(title);
    Window wnd = getDialog().getWindow();
    if (wnd != null)
        wnd.getAttributes().windowAnimations = R.style.dialog_animation;

    Button dismiss = root.findViewById(R.id.numeric_done);
    dismiss.setOnClickListener((View v) -> done());

    this.maxLength = maxLength;
    numericInputManager = new NumericInputManager(maxLength);

    intStack = new Stack<>();
    valueEnteredTV = root.findViewById(R.id.value_entered);

    initButtons();
    initRestrictions();
}
Markus Steppberger
  • 618
  • 1
  • 8
  • 18
George
  • 2,865
  • 6
  • 35
  • 59

1 Answers1

1

Add <item name="android:dialogTheme">@style/CustomDialog</item> on your AppTheme like

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="android:dialogTheme">@style/CustomDialog</item>
</style>
DAG
  • 6,710
  • 4
  • 39
  • 63
Tshego
  • 126
  • 2
  • 8