Black text on dark background on Nougat (android.R.layout.simple_spinner_item)
Asked Answered
H

2

14

I have some basic piece of code on a Welcome Activity that simply binds List adapter as usual:

final ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, android.R.id.text1);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

This used to work until I updated to API level 25. At that point, with no other changes, the spinner dropdown's text has become un-readable:

black text on dark background android 7

My theme's parent is "Theme.AppCompat.Light.NoActionBar" but again, I'm not playing with colors there and nothing changed since when it was showing correctly (API < 25). Any idea?

I know I could fix it with some setTextColor() inside spinner.setOnItemSelectedListener(), but the main point is understanding why it was working and now it doesn't, as this may be a sign of something conceptuyally wrong on my side, or even some kind of Android bug. Infact, i noticed the same problem (black text on dark background) on pretty standard widgets/app, like the Cyanogen/LineageOS default weather one:

black text on dark background android 7

Hexad answered 23/1, 2017 at 15:48 Comment(4)
Let me check, didnt see that you are using the Android spinner itemCarbuncle
I have the exact same problem. I know level 20 is good. both 24 and 25 are bad.Sike
I have the exact same problem. It's working fine on level 20. After upgrading to 25, it has this problem. However, even if I downgrade from level 25 to level 20, it still doesn't work.Sike
@Sike Did you find a solution?Psychotic
K
0

I had same issue. Your color definition may be android:textColor="#FFFFFFFF". When I fixed it as android:textColor="#FF000000", it is working fine. Or you can use android:textColor="#FFFFFFFF".

I heard from my co-working, the first 2 hex meaning is changed. It is changed the SDK version 24.

Kindless answered 10/7, 2019 at 2:40 Comment(0)
Y
0

For me the problem was that at run time when I try to create the spinner the colors are buggy so I made a workaround making a layou with the color I wanted in the text and setting this layout when in dark mode, just making it clear I used the default theme at the beginning of the tests but it also doesn't work and neither what I created and put in the color.xml files worked

/* Start Workaround */
int layout = R.layout.simple_spinner_item_black;
if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES){layout = R.layout.simple_spinner_item_white;}
/* End Workaround */
Yu answered 30/3, 2021 at 11:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.