我想为 ProgressDialog 设置合适的样式。 我喜欢默认的,但我想自定义它。我曾尝试使用 AppCompat 对话框,但它们都为我的对话框设置了一些奇怪的宽度和高度。
我发现从 MaterialDialog 扩展可以达到目的,所以这段代码有效:
<style name="ProgressDialogTheme" parent="MaterialBaseTheme.AlertDialog" >
</style>
这是因为MeterialDialog本身设置了自定义宽度
<style name="MaterialBaseTheme.AlertDialog" parent="MaterialBaseTheme.Dialog">
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
</style>
而且我发现有设置相同自定义宽度的 AppCompat 对话框,这里是:
<style name="Base.Theme.AppCompat.Light.Dialog.Alert">
<item name="windowMinWidthMajor">@dimen/abc_dialog_min_width_major</item>
<item name="windowMinWidthMinor">@dimen/abc_dialog_min_width_minor</item>
</style>
但它不起作用
唯一的区别是 MeterialDialog 属性开头的 andorid 命名空间。
有人可以解释为什么 android:windowMinWidthMajor
成功了吗?
最佳答案
根据 this link :
Min_witdh_major 是:
The platform's desired minimum size for a dialog's width when it is along the major axis (that is the screen is landscape). This may be either a fraction or a dimension.
而 min_with_minor 是:
The platform's desired minimum size for a dialog's width when it is along the minor axis (that is the screen is portrait). This may be either a fraction or a dimension.
在appcompat中,这个值设置为65%。
关于android - windowMinWidthMajor 和 android :windowMinWidthMajor 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40302941/