Search code examples
androidlook-and-feelbrandingandroid-theme

How to get device colors?


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.

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


Solution

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

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

    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;
        }
    }