如何让Android系统的颜色 [英] How to Get Android System Colors

查看:127
本文介绍了如何让Android系统的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了如何设置系统颜色引用,但我需要找出如何让他们 - 你怎么找出它们是什么

I've seen references on how to SET system colours, but I need to find out how you GET them - how do you find out what they are?

在三星的Galaxy S为例,该选项卡视图,ListView的亮点,当你选择一个项目,和preference屏幕上的摘要文本行都是蓝色的。

On the Samsung Galaxy S for example, the tab views, ListView highlights when you select an item, and the Summary text line on the preference screen are all blue.

有哪些immitate这种风格的许多应用程序,我想这样做。很显然,我不能就这么难code和颜色设置为蓝色,其他手机使用不同的颜色。

There are many apps which immitate this style and I want to do the same. Obviously I cannot just hard code and set the colour to Blue, as other handsets use different colours.

现在的问题是,有没有办法以编程方式找出什么颜色的preference屏幕摘要行,制表符,或ListView选择是,这样你就可以设置,对你的应用在其他地方一个TextView?

The question is, is there a way to programmatically find out what colour the Preference Screen Summary Line, Tabs, or ListView selections are, so that you can then set that against a TextView elsewhere in your app?

我如何获得Android系统的颜色?

How do I get the android system colours?

推荐答案

有一个回答这个问题,但它可能不是你想听到的人。没有办法可靠地做到这一点。 选择颜色其实是一个九修补形象,这是提供了一个平台特定的基础上的一部分。一些使用标准的橙色,有些(感应)采用绿色,其他人使用红色。随着这些的详尽清单则可能能够创建从硬件到颜色的映射,但是这不是很有效的,因为新的硬件出来所有的时间,和一些这些手机允许感被卸载。

There is an answer to this question, but it is probably not the one you wanted to hear. There is no way to reliably do this. The "selection color" is actually part of a nine-patch image, which is provided on a platform specific basis. Some use the standard orange color, some (Sense) uses green, and others use red. With an exhaustive list of these you might be able to create a mapping from hardware to color, but this is not very effective because new hardware comes out all the time, and some of these phones allow sense to be uninstalled.

只有真实的东西,你可以做的是让应用程序本身,这是一个够硬任务本身在您的按钮是一致的。如果你真的有一个选择颜色的自定义项(这是相当普及了),那么我的建议是从您所选择的平台复制按钮资源(我喜欢默认的SDK资源,我自己),然后手动设置整个应用程序。这样,他们将永远看起来是一样的,不管你是在哪个平台上,所以总是会符合您的自定义视图。请注意,这将要求您的不仅仅是按钮做多。对话框和菜单也将需要被修改,这是可能的,但是硬

The only real thing you can do is to make your buttons consistent within the application itself, which is a hard enough task by itself. If you really have to have a custom item with a selection color (which is common enough), then my advice would be to copy the button resources from the platform of your choice (I like the default sdk resources myself) and then manually set them throughout your application. This way they will always look the same no matter which platform you are on, and so will always match your custom views. Note that this will require you to do more than just buttons. Dialogs and menus also will need to be modified, which is possible, but hard.

这真的是在路上的Andr​​oid的设计缺陷,并导致我们很多的悲伤。我希望我有更好的回答你,但我认为这是我们已经得到了最好的。

Really this is a flaw in the way Android was designed, and it causes a lot of us grief. I wish I had a better answer for you, but I think this is the best we've got.

这篇关于如何让Android系统的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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