我正在为我的AlertDialogs使用自定义样式,但它使它们显示为全屏。我四处搜索,但我似乎只能找到想要全屏显示的人......
这是我的风格
<style name="MyDialog" parent="AlertDialog.AppCompat">
<item name="android:background">@color/material_dark</item>
<item name="android:layout_height">100dp</item>
<item name="android:textColor">@color/accent</item>
<item name="android:textColorPrimary">@color/material_white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
还有我AlertDialog的一个。
AlertDialog alertDialog = new AlertDialog.Builder(this.getContext(), R.style.MyDialog)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(this.getContext().getResources().getString(R.string.reset) + "?")
.setMessage(this.getContext().getResources().getString(R.string.AreYouSure))
.setPositiveButton(getString(R.string.yes), (dialog, which) -> {
reset();
})
.setNegativeButton(getString(R.string.notReally), (dialog, which) ->{
//Do nothing
})
.show();
Run Code Online (Sandbox Code Playgroud)
这就是它的样子。我不知道为什么它占据了整个屏幕。它应该看起来像AlertDialog自定义颜色。
android presentation android-alertdialog android-styles android-5.0-lollipop