【问题标题】:change and customize Alert Dialog appearance in android更改和自定义 android 中的警报对话框外观
【发布时间】:2015-12-14 16:24:37
【问题描述】:

也许这是一个简单的问题,但它太奇怪了!我想更改和自定义我的警报对话框。我在样式文件中使用此代码,但我的警报对话框外观没有变化。

 <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="android:alertDialogStyle">@style/AD_Style</item>
</style>

   <style name="AD_Style" parent="@android.widget.Holo">
     <item name="android:background">@drawable/curved_background</item>
    <item name="android:textColor">#ffffff</item>
    <item name="android:textSize">25sp</item>
</style>

最后,是否可以更改警报对话框颜色的按钮?谢谢!

 09-18 14:57:11.738    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:57:11.753    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 14:57:11.983    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:57:20.178    1884-2635/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:57:20.178    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 14:57:20.408    1884-2635/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:57:27.578    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:57:27.578    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 14:57:27.808    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:11.973    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:11.973    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 14:58:12.203    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:16.628    1884-2635/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:16.638    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 14:58:16.868    1884-2635/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:21.628    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:21.628    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 14:58:21.863    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:22.113    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:22.378    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:22.623    1884-2635/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:22.883    1884-2635/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:23.493    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:23.773    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:25.408    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:25.668    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:26.543    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:26.808    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:30.308    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:30.313    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 14:58:30.488    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:31.478    1884-2155/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:31.743    1884-2155/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:31.818    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:32.088    1884-2155/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:58:34.773   1884-10288/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:55.618    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:58:55.688    1884-2155/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 184
09-18 14:58:55.888    1884-2155/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:59:00.008    1884-2635/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:59:00.008    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 14:59:00.283    1884-2635/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 14:59:01.008    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 14:59:01.258    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 15:00:58.088    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 15:00:58.098    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 15:00:58.328    1884-2635/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 15:01:00.793    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 15:01:01.043    1884-2636/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184
09-18 15:01:04.208    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0002 force 0 delayMs 0
09-18 15:01:04.223    1884-2154/? D/AudioHardwareTinyALSA﹕ OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
09-18 15:01:04.393    1884-1884/? V/AudioPolicyManagerBase﹕ setOutputDevice() output 2 device 0000 force 0 delayMs 184

【问题讨论】:

  • 我的基本问题是,“alertDialogStyle”用于更改警报对话框的视图,但它没有改变,为什么?
  • 如果我使用“alertDialogTheme”或“build = new AlertDialog.Builder(MyActivity.this,R.style.AD_Style);”我的 AlertDialog 使用该样式覆盖了所有屏幕(作为 Activity)。为什么?

标签: android android-alertdialog


【解决方案1】:
View dialog = inflater.inflate(R.layout.dialog_layout, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(dialog);
builder.show();

这里我使用自定义警报对话框

【讨论】:

【解决方案2】:

看看这个类似的问题:

How to create a completely custom Dialogue/Popup in Android (change overlay colour and dialogue window layout)

前几天我用它来调整一个。

让我知道它是否适合你。

【讨论】:

  • 我读过,但没有找到答案。你能准确回答我吗?
  • 你弄明白了吗?
  • 哦,不!奇怪的是,我每尝试一次,警报对话框都会作为一个活动覆盖整个屏幕!!!
猜你喜欢
  • 2015-04-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多