我具有以下显示对话框标题的样式
<style name="CustomDialog" parent="@style/Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">false</item>
</style>
但是,该对话框不显示标题。该对话框看起来像下的图像。我还提供了用于初始化视图的代码
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();
}
答案 0 :(得分:1)
在您的AppTheme上添加<item name="android:dialogTheme">@style/CustomDialog</item>
,例如
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:dialogTheme">@style/CustomDialog</item>
</style>