【问题标题】:Android material dialog actions panel heightAndroid材质对话框动作面板高度
【发布时间】:2020-06-29 11:19:14
【问题描述】:

这里是官方材质对话框规范:

我想增加操作面板高度 (52dp)/paddings(8dp) 以在按钮周围获得更多空间。有没有合适的方法通过样式来做到这一点?

【问题讨论】:

    标签: android material-design android-styles android-dialog material-components-android


    【解决方案1】:

    你可以这样做:

    <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();
    

    【讨论】:

      【解决方案2】:

      您有多种选择,例如:

      • 在您自己的 dimens.xml 中覆盖默认材料尺寸(不推荐)
      • 通过从组件的 Material 主题继承主题来创建自己的样式

      请看一下这个例子,你应该会找到你需要的:

      https://medium.com/over-engineering/setting-up-a-material-components-theme-for-android-fbf7774da739

      【讨论】:

        猜你喜欢
        • 2020-02-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-01
        • 1970-01-01
        • 2021-08-22
        • 2017-11-02
        • 1970-01-01
        相关资源
        最近更新 更多