Question

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?

Was it helpful?

Solution 2

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

OTHER TIPS

All the customizations done by carries/manufactures are inside:

  • android:colors
  • android:styles
  • android:themes

If you are using a TextView you can check the default text color by creating a TextView object and calling getTextColors().

Another possibility is checking how the styles are applied to the TextView and using the getResource() method to get the exact color you are looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top