【问题标题】:Android Dialog in Custom Style: Remove Blue Line and set ActionBar Color自定义样式中的 Android 对话框:删除蓝线并设置 ActionBar 颜色
【发布时间】:2015-03-30 05:38:02
【问题描述】:

我正在使用以下代码和视图创建一个自定义对话框,如下所示: mCountryDialog = new Dialog(getActivity(),android.R.style.Theme_Holo); 但是,我想删除蓝色分隔线并更改“操作栏”的背景颜色

尝试的结果 参考stackoverflow,我在style.xml中创建了一个自定义对话框样式

`<style name="LoCountryDialog" parent="android:Theme.Holo"> 
<item name="android:windowFullscreen">true</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">false</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@color/main_theme_red</item>

`

我会将背景颜色从黑色更改为红色,但显示时间、电池电量等的“顶部栏”消失了,蓝色分隔线仍然保留在此处。 如果有人能与我分享解决方案,那就太好了,非常感谢!

【问题讨论】:

  • 我使用该工具生成了一个自定义的editText框,这很有用。但是,这次我想在对话框中更改操作栏的颜色..您是否可以给我更多关于使用该工具的提示,非常感谢!!

标签: android dialog


【解决方案1】:

只需将此行添加到您的 Dialog.onCreateView() 方法中:

getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

【讨论】:

  • 但我想保留标题的内容,我想要的只是删除“下划线”..
【解决方案2】:

http://jgilfelt.github.io/android-actionbarstylegenerator

它将生成所有必需的九个补丁资源以及相关的 XML 可绘制对象和样式,您可以将它们直接复制到您的项目中。

你用这些类似的样式创建一个主题

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme" parent="@style/Theme.Holo.Light.DarkActionBar">
       <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

<!-- ActionBar styles -->
  <style name="MyActionBar" parent="@style/Widget.Holo.Light.ActionBar.Solid.Inverse">
       <item name="android:background">#ff0000</item>
  </style>
</resources>

在此之后,您将主题应用到您的整个应用或单个活动:

如需进一步阅读,请参阅documentation

【讨论】:

  • 我想我明白了你的想法。我稍后会尝试您的方法,如果成功,我会接受这个作为答案。提前致谢!
猜你喜欢
  • 1970-01-01
  • 2013-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-05
  • 2013-12-18
相关资源
最近更新 更多