<legend id='n9Y5a'><style id='n9Y5a'><dir id='n9Y5a'><q id='n9Y5a'></q></dir></style></legend>

      <small id='n9Y5a'></small><noframes id='n9Y5a'>

      • <bdo id='n9Y5a'></bdo><ul id='n9Y5a'></ul>
      <tfoot id='n9Y5a'></tfoot>

    1. <i id='n9Y5a'><tr id='n9Y5a'><dt id='n9Y5a'><q id='n9Y5a'><span id='n9Y5a'><b id='n9Y5a'><form id='n9Y5a'><ins id='n9Y5a'></ins><ul id='n9Y5a'></ul><sub id='n9Y5a'></sub></form><legend id='n9Y5a'></legend><bdo id='n9Y5a'><pre id='n9Y5a'><center id='n9Y5a'></center></pre></bdo></b><th id='n9Y5a'></th></span></q></dt></tr></i><div id='n9Y5a'><tfoot id='n9Y5a'></tfoot><dl id='n9Y5a'><fieldset id='n9Y5a'></fieldset></dl></div>

        Appcompat 警报对话框操作按钮背景 按下状态

        时间:2023-08-28

          1. <legend id='wi04Q'><style id='wi04Q'><dir id='wi04Q'><q id='wi04Q'></q></dir></style></legend>

                <tbody id='wi04Q'></tbody>
                <bdo id='wi04Q'></bdo><ul id='wi04Q'></ul>
                  <tfoot id='wi04Q'></tfoot>

                  <small id='wi04Q'></small><noframes id='wi04Q'>

                  <i id='wi04Q'><tr id='wi04Q'><dt id='wi04Q'><q id='wi04Q'><span id='wi04Q'><b id='wi04Q'><form id='wi04Q'><ins id='wi04Q'></ins><ul id='wi04Q'></ul><sub id='wi04Q'></sub></form><legend id='wi04Q'></legend><bdo id='wi04Q'><pre id='wi04Q'><center id='wi04Q'></center></pre></bdo></b><th id='wi04Q'></th></span></q></dt></tr></i><div id='wi04Q'><tfoot id='wi04Q'></tfoot><dl id='wi04Q'><fieldset id='wi04Q'></fieldset></dl></div>

                  本文介绍了Appcompat 警报对话框操作按钮背景 按下状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试 appcompat v7 22.1.1 中的新 AlertDialog.

                  I am trying new AlertDialog from appcompat v7 22.1.1.

                  效果很好(在所有 android 版本中),如图所示.

                  It works pretty well (In all android versions) as in image.

                  AlertDialog 的样式是这样的.(现在我使用的是硬编码的颜色值而不是颜色资源)

                  Style for AlertDialog is this. (For now I am using hardcoded color values instead of color resources)

                  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
                  
                              <item name="colorPrimaryDark">#111111</item>
                  
                              <item name="colorPrimary">#00ddff</item>
                  
                              <item name="colorAccent">#0044aa</item>
                  
                              <item name="colorButtonNormal">#00aaaa</item>
                  
                              <item name="colorControlHighlight">#00ddff</item>
                  
                              <item name="alertDialogTheme">@style/AlertDialogTheme</item>
                  
                  </style>
                  <style name="AlertDialogTheme" parent="Theme.AppCompat.Dialog.Alert">
                                  <item name="colorAccent">#0044aa</item>
                                  <item name="android:background">#ffffff</item>
                                  <item name="android:textColorPrimary">#000000</item>
                                  <item name="android:windowTitleStyle">@style/MyTitleTextStyle</item>
                  </style>
                  
                  <style name="MyTitleTextStyle">
                                  <item name="android:textColor">#0044aa</item>
                                  <item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
                  </style>
                  

                  我的问题是,

                  1) 如何改变图片中圆角(灰色)的 statePressed 颜色?

                  2) android >= 21 中没有按下颜色,这有什么技巧?

                  2) No pressed color is there in android >= 21 , what is hack for this ?

                  3) 我怎样才能有不同颜色的动作按钮(有可能)?

                  3) How can I have different colors of action buttons (Is it possible)?

                  任何帮助都会很棒.

                  推荐答案

                  可以使用样式属性如

                  • buttonBarButtonStyle
                  • buttonBarNegativeButtonStyle
                  • buttonBarNeutralButtonStyle
                  • buttonBarPositiveButtonStyle

                  例子:

                  <style name="dialog_theme" parent="Theme.AppCompat.Dialog.Alert">
                      <item name="buttonBarNegativeButtonStyle">@style/dialog_button.negative</item>
                      <item name="buttonBarPositiveButtonStyle">@style/dialog_button.positive</item>
                  </style>
                  
                  <style name="dialog_button">
                      <item name="android:textStyle">bold</item>
                      <item name="android:minWidth">64dp</item>
                      <item name="android:paddingLeft">8dp</item>
                      <item name="android:paddingRight">8dp</item>
                      <item name="android:background">@drawable/dialogButtonSelector</item>
                  </style>
                  
                  <style name="dialog_button.negative">
                      <item name="android:textColor">#f00</item>
                  </style>
                  
                  <style name="dialog_button.positive">
                      <item name="android:layout_marginLeft">8dp</item>
                      <item name="android:textColor">#00f</item>
                  </style>
                  

                  其中 dialogBu​​ttonSelector 是我们的自定义可绘制选择器.

                  Where dialogButtonSelector is our custom drawable selector.

                  不幸的是,在 dialog_button 上设置背景会破坏我们的填充和边距,所以我需要重新设置它.

                  Unfortunatelly setting background on dialog_button destroy our paddings and margins so I need to set it again.

                  dialog_button 样式可以通过 Widget.AppCompat.Button.ButtonBar.AlertDialog 继承,但我发现它缺少像 textStyle 粗体.

                  dialog_button style can inherit through Widget.AppCompat.Button.ButtonBar.AlertDialog but I found that it has missing styles like textStyle bold.

                  这篇关于Appcompat 警报对话框操作按钮背景 按下状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:android中的警报对话框不应关闭 下一篇:仅使用 Context 而不是 Activity 实例显示对话框

                  相关文章

                  最新文章

                    1. <tfoot id='kT1vq'></tfoot>
                      <legend id='kT1vq'><style id='kT1vq'><dir id='kT1vq'><q id='kT1vq'></q></dir></style></legend>

                        <bdo id='kT1vq'></bdo><ul id='kT1vq'></ul>
                      <i id='kT1vq'><tr id='kT1vq'><dt id='kT1vq'><q id='kT1vq'><span id='kT1vq'><b id='kT1vq'><form id='kT1vq'><ins id='kT1vq'></ins><ul id='kT1vq'></ul><sub id='kT1vq'></sub></form><legend id='kT1vq'></legend><bdo id='kT1vq'><pre id='kT1vq'><center id='kT1vq'></center></pre></bdo></b><th id='kT1vq'></th></span></q></dt></tr></i><div id='kT1vq'><tfoot id='kT1vq'></tfoot><dl id='kT1vq'><fieldset id='kT1vq'></fieldset></dl></div>

                      <small id='kT1vq'></small><noframes id='kT1vq'>