Android 材质对话框操作面板高度
Android material dialog actions panel height
这是官方的材质对话框规范:
我想增加操作面板的高度 (52dp)/填充 (8dp) 以获得更多 space 按钮周围。有没有合适的方法通过样式来做到这一点?
您有多种选择,例如:
- 在您自己的 dimens.xml 中覆盖默认 material 维度(不推荐)
- 通过从组件的 Material 主题继承您的主题来创建您自己的样式
请看看这个例子,你应该找到你需要的:
https://medium.com/over-engineering/setting-up-a-material-components-theme-for-android-fbf7774da739
您可以使用:
<style name="AlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="buttonBarStyle">@style/myButtonBar</item>
</style>
<style name="myButtonBar" parent="Widget.AppCompat.ButtonBar">
<item name="android:paddingTop">32dp</item>
<item name="android:paddingBottom">32dp</item>
</style>
然后只需使用:
new MaterialAlertDialogBuilder(context,R.style.AlertDialog)
.setTitle("...")
.setMessage(".....")
...
.show();
这是官方的材质对话框规范:
我想增加操作面板的高度 (52dp)/填充 (8dp) 以获得更多 space 按钮周围。有没有合适的方法通过样式来做到这一点?
您有多种选择,例如:
- 在您自己的 dimens.xml 中覆盖默认 material 维度(不推荐)
- 通过从组件的 Material 主题继承您的主题来创建您自己的样式
请看看这个例子,你应该找到你需要的:
https://medium.com/over-engineering/setting-up-a-material-components-theme-for-android-fbf7774da739
您可以使用:
<style name="AlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="buttonBarStyle">@style/myButtonBar</item>
</style>
<style name="myButtonBar" parent="Widget.AppCompat.ButtonBar">
<item name="android:paddingTop">32dp</item>
<item name="android:paddingBottom">32dp</item>
</style>
然后只需使用:
new MaterialAlertDialogBuilder(context,R.style.AlertDialog)
.setTitle("...")
.setMessage(".....")
...
.show();