我怎样才能改变AlertDialog标题的颜色和线下它的颜色 [英] How can I change the color of AlertDialog title and the color of the line under it

查看:195
本文介绍了我怎样才能改变AlertDialog标题的颜色和线下它的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我改变了一个AlertDialog标题中使用此命令的颜色

I changed the color of an AlertDialog title using this command

alert.setTitle( Html.fromHtml("<font color='#FF7F27'>Set IP Address</font>"));

不过,我想改变这种状况出现的标题下的线的颜色;我该怎么办呢?

But I want to change the color of the line that appear under the title; how can I do that ?

注:我不想用自定义布局

Note: I don't want to use a custom layout

推荐答案

不幸的是,这不是一个特别简单的任务来完成。 <一href="http://stackoverflow.com/questions/12171209/change-the-line-color-used-in-listseparatortextviewstyle/12172490#12172490">In这里我的回答,我详细介绍如何调整的颜色 ListSeparator ,只需检查出使用Android的父样式,创建一个新的形象,并创建新款在原有基础上的。不幸的是,不像与 ListSeparator 的风格, AlertDialog 的主题是内部的,因此不能被引用为母风格。有没有简单的方法来改变这一小蓝线!因此,你需要求助于制作自定义对话框。

Unfortunately, this is not a particularly simple task to accomplish. In my answer here, I detail how to adjust the color of a ListSeparator by just checking out the parent style used by Android, creating a new image, and creating a new style based on the original. Unfortunately, unlike with the ListSeparator's style, AlertDialog themes are internal, and therefore cannot be referenced as parent styles. There is no easy way to change that little blue line! Thus you need to resort to making custom dialogs.

如果,仅仅是不是你杯茶...... 不要放弃!我感到非常不安,有没有简单的方法来做到这一点,所以我就成立了一个小项目GitHub上作出快速定制全息式对话框(假设手机支持霍洛风格)。 您可以在这里找到的项目:<一href="https://github.com/danoz73/QustomDialog">https://github.com/danoz73/QustomDialog

If that just isn't your cup of tea... don't give up! I was very disturbed that there was no easy way to do this so I set up a little project on github for making quickly customized holo-style dialogs (assuming that the phone supports the Holo style). You can find the project here: https://github.com/danoz73/QustomDialog

这应该很容易能够从乏味的蓝色令人兴奋的橙去!

It should easily enable going from boring blue to exciting orange!

该项目基本上是使用自定义对话框生成器的一个例子,在这个例子中,我创建这似乎迎合你给你的原来问题的IP地址例如自定义视图。

The project is basically an example of using a custom dialog builder, and in the example I created a custom view that seemed to cater to the IP Address example you give in your original question.

使用 QustomDialog ,以创建一个基本的对话(标题,消息)与期望的不同颜色的标题或分隔,可以使用下面的code

With QustomDialog, in order to create a basic dialog (title, message) with a desired different color for the title or divider, you use the following code:

private String HALLOWEEN_ORANGE = "#FF7F27";

QustomDialogBuilder qustomDialogBuilder = new QustomDialogBuilder(v.getContext()).
    setTitle("Set IP Address").
    setTitleColor(HALLOWEEN_ORANGE).
    setDividerColor(HALLOWEEN_ORANGE).
    setMessage("You are now entering the 10th dimension.");

qustomDialogBuilder.show();

和以添加自定义布局(比如,添加少许的IP地址的EditText ),添加

And in order to add a custom layout (say, to add the little IP address EditText), you add

setCustomView(R.layout.example_ip_address_layout, v.getContext())

要与你设计(知识产权例子可以在GitHub上找到)的布局建设者。我希望这有助于。 <一href="http://stackoverflow.com/questions/2422562/how-to-change-theme-for-alertdialog/5392617#5392617">Many感谢约瑟夫伯爵和他的答案这里。

to the builder with a layout that you have designed (the IP example can be found in the github). I hope this helps. Many thanks to Joseph Earl and his answer here.

这篇关于我怎样才能改变AlertDialog标题的颜色和线下它的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆