android Theme.Holo.Dialog 将蓝线更改为橙色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10057859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:20:36  来源:igfitidea点击:

android Theme.Holo.Dialog changing blue lines to orange

androidcolorsstylesthemes

提问by butelo

Default color for lines on Android theme Theme.Holo.Dialog are blue. I'd like to know how to change this to any other color. Orange in my case

Android 主题 Theme.Holo.Dialog 线条的默认颜色为蓝色。我想知道如何将其更改为任何其他颜色。橙色在我的情况下

I can change text or background etc.. orveriding the theme with a custom style.xml

我可以更改文本或背景等。或者使用自定义 style.xml 验证主题

   <style name="Theme.MyTheme" parent="@android:style/Theme.Holo.Dialog" >
        <item name="android:textColor">@color/coloroscuro</item>
        <item name="android:textColorHint">@color/coloroscuro</item>
   </style>

but I don't know wich property manages the color of the lines

但我不知道哪个属性管理线条的颜色

I mean the blue lines that the theme has by default like the ones shown on this other question:

我的意思是主题默认的蓝线,就像另一个问题中显示的蓝线:

How to Android Holo Theme style dialog box buttons

如何 Android Holo Theme 风格的对话框按钮

Tx

发送

采纳答案by David Vávra

There is a library which does exactly what you need - easy styling of dialogs in Holo theme:

有一个库可以完全满足您的需求 - Holo 主题中对话框的简单样式:

https://github.com/inmite/android-styled-dialogs

https://github.com/inmite/android-styled-dialogs

回答by JRaymond

Just dug around in the source for you - unfortunately the Divider line in the dialog layouts is a view with a hard coded color background that doesn't reference any themes:

只需为您挖掘源代码 - 不幸的是,对话框布局中的分隔线是一个带有硬编码颜色背景的视图,不引用任何主题:

<View android:id="@+id/titleDividerTop"
  android:layout_width="match_parent"
  android:layout_height="2dip"
  android:visibility="gone"
  android:background="@android:color/holo_blue_light" />

So if you want to change the color you'll have to layout your own, custom, dialog box. to make it easier, it wouldn't hurt to just copy from the android source base and customize it to your needs, but you might also get a lot more than you need.

因此,如果您想更改颜色,则必须布局您自己的自定义对话框。为了使它更容易,只需从 android 源代码库复制并根据您的需要对其进行自定义不会有什么坏处,但您也可能会得到比您需要的更多的东西。

回答by Navid Einackchi

one trick is using dialog with no title bar, hence android not draw the line, then adding title and the line yourself in dialog`s layout xml file! for example:

一个技巧是使用没有标题栏的对话框,因此android不会画线,然后在对话框的布局xml文件中自己添加标题和线!例如:

<style name="myDialogStyle" parent="android:style/Theme.Holo.Dialog">
    <item name="android:windowNoTitle">true</item>
</style>

in manifest use:

在清单使用中:

    <activity
        android:name=".Activity.Mydialog"
        android:theme="@style/myDialogStyle" >
    </activity>

and in your Mydialog layout define title and line yourself with your desired color and style!

并在您的 Mydialog 布局中定义标题并用您想要的颜色和样式排列自己!

cheers!

干杯!