如何获得设备的颜色? [英] How to get device colors?

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

问题描述

我有一个微调是在模拟器上浅灰色与黑色文本还对HTC设备。在摩托罗拉Defy的控制是暗灰色和文字是白色的。

I have a spinner which is in the Emulator light gray with black text also on HTC devices. On the Motorola Defy the control is dark-gray and the text is white.

我怎样才能获得currient设备的默认文本颜色?

How can I get the default text color of the currient device?

推荐答案

Macarse的答案去在正确的方向,但我用另一种方式。

The answer of Macarse goes in the right direction but I uses another way.

我看着在 /平台/ Android的X /数据/ RES /值 XML文件,并得到了颜色 background_dark 这为我工作。

I looked in the /platforms/android-X/data/res/values xml files and got the color background_dark which works for me.

Finnally我用这个code:

Finnally I uses this code:

public class MyAdapter extends ArrayAdapter<SpinnerItem> {
    // ...

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        View v = super.getDropDownView(position, convertView, parent);
        TextView tv=(TextView)v.findViewById(android.R.id.text1);
        tv.setTextColor(Resources.getSystem().getColor(android.R.color.background_dark));
        return v;
    }
}

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

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