Selected item in spinner is white in android versions lowwer or equal to 23
In my activity inside oncreate I instantiate and set adapter to the Spinner like this
...
ArrayAdapter arrayAdapter = new ArrayAdapter<>(this
, android.R.layout.simple_spinner_item, members);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
memberSpinner.setAdapter(arrayAdapter);
In the xml i declare spinner like this
...
<Spinner
android:id="@+id/sp_members"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
/>
I have this base theme for application which i suspect is the cause of this
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
In android api level 24 and above which i have tested the image is like this..
Image in android 7 device
And below something like this...
Image in android 5 device
PLEASE HOW CAN I MAKE SURE THE SELECTED SPINNER ITEM IS ALWAYS BLACK IN COLOR. (So that it is always easily readable)
android-spinner
add a comment |
In my activity inside oncreate I instantiate and set adapter to the Spinner like this
...
ArrayAdapter arrayAdapter = new ArrayAdapter<>(this
, android.R.layout.simple_spinner_item, members);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
memberSpinner.setAdapter(arrayAdapter);
In the xml i declare spinner like this
...
<Spinner
android:id="@+id/sp_members"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
/>
I have this base theme for application which i suspect is the cause of this
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
In android api level 24 and above which i have tested the image is like this..
Image in android 7 device
And below something like this...
Image in android 5 device
PLEASE HOW CAN I MAKE SURE THE SELECTED SPINNER ITEM IS ALWAYS BLACK IN COLOR. (So that it is always easily readable)
android-spinner
Please I have looked at almost all the spinner related question and tried solutions like using a custom layout for spinner item or drop down list. But to no avail. I am not familiar with themes and how to tweak them to suite my needs. I just want the spinner to look presentable in all versions
– N.Hubert
Nov 15 '18 at 11:29
please look perfectly two images. background color change so i think you use different different theme for both.
– Ali
Nov 15 '18 at 11:33
I did not fully understand the question, for is the problem with the spinner?
– AnteGemini
Nov 15 '18 at 13:19
@AnteGeminithe don't know if the problem is with spinner or the theme which is used in the application. But if you view those images i shared in the question you see clearly that in one device the selected spinner item is white while in another it is black. Yet both devices are running thesame app. Now my worry is that the spinner would not readable with it appears white
– N.Hubert
Nov 15 '18 at 15:31
@Ali please explain more
– N.Hubert
Nov 15 '18 at 15:39
add a comment |
In my activity inside oncreate I instantiate and set adapter to the Spinner like this
...
ArrayAdapter arrayAdapter = new ArrayAdapter<>(this
, android.R.layout.simple_spinner_item, members);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
memberSpinner.setAdapter(arrayAdapter);
In the xml i declare spinner like this
...
<Spinner
android:id="@+id/sp_members"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
/>
I have this base theme for application which i suspect is the cause of this
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
In android api level 24 and above which i have tested the image is like this..
Image in android 7 device
And below something like this...
Image in android 5 device
PLEASE HOW CAN I MAKE SURE THE SELECTED SPINNER ITEM IS ALWAYS BLACK IN COLOR. (So that it is always easily readable)
android-spinner
In my activity inside oncreate I instantiate and set adapter to the Spinner like this
...
ArrayAdapter arrayAdapter = new ArrayAdapter<>(this
, android.R.layout.simple_spinner_item, members);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
memberSpinner.setAdapter(arrayAdapter);
In the xml i declare spinner like this
...
<Spinner
android:id="@+id/sp_members"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
/>
I have this base theme for application which i suspect is the cause of this
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
In android api level 24 and above which i have tested the image is like this..
Image in android 7 device
And below something like this...
Image in android 5 device
PLEASE HOW CAN I MAKE SURE THE SELECTED SPINNER ITEM IS ALWAYS BLACK IN COLOR. (So that it is always easily readable)
android-spinner
android-spinner
edited Nov 15 '18 at 15:43
N.Hubert
asked Nov 15 '18 at 11:26
N.HubertN.Hubert
12
12
Please I have looked at almost all the spinner related question and tried solutions like using a custom layout for spinner item or drop down list. But to no avail. I am not familiar with themes and how to tweak them to suite my needs. I just want the spinner to look presentable in all versions
– N.Hubert
Nov 15 '18 at 11:29
please look perfectly two images. background color change so i think you use different different theme for both.
– Ali
Nov 15 '18 at 11:33
I did not fully understand the question, for is the problem with the spinner?
– AnteGemini
Nov 15 '18 at 13:19
@AnteGeminithe don't know if the problem is with spinner or the theme which is used in the application. But if you view those images i shared in the question you see clearly that in one device the selected spinner item is white while in another it is black. Yet both devices are running thesame app. Now my worry is that the spinner would not readable with it appears white
– N.Hubert
Nov 15 '18 at 15:31
@Ali please explain more
– N.Hubert
Nov 15 '18 at 15:39
add a comment |
Please I have looked at almost all the spinner related question and tried solutions like using a custom layout for spinner item or drop down list. But to no avail. I am not familiar with themes and how to tweak them to suite my needs. I just want the spinner to look presentable in all versions
– N.Hubert
Nov 15 '18 at 11:29
please look perfectly two images. background color change so i think you use different different theme for both.
– Ali
Nov 15 '18 at 11:33
I did not fully understand the question, for is the problem with the spinner?
– AnteGemini
Nov 15 '18 at 13:19
@AnteGeminithe don't know if the problem is with spinner or the theme which is used in the application. But if you view those images i shared in the question you see clearly that in one device the selected spinner item is white while in another it is black. Yet both devices are running thesame app. Now my worry is that the spinner would not readable with it appears white
– N.Hubert
Nov 15 '18 at 15:31
@Ali please explain more
– N.Hubert
Nov 15 '18 at 15:39
Please I have looked at almost all the spinner related question and tried solutions like using a custom layout for spinner item or drop down list. But to no avail. I am not familiar with themes and how to tweak them to suite my needs. I just want the spinner to look presentable in all versions
– N.Hubert
Nov 15 '18 at 11:29
Please I have looked at almost all the spinner related question and tried solutions like using a custom layout for spinner item or drop down list. But to no avail. I am not familiar with themes and how to tweak them to suite my needs. I just want the spinner to look presentable in all versions
– N.Hubert
Nov 15 '18 at 11:29
please look perfectly two images. background color change so i think you use different different theme for both.
– Ali
Nov 15 '18 at 11:33
please look perfectly two images. background color change so i think you use different different theme for both.
– Ali
Nov 15 '18 at 11:33
I did not fully understand the question, for is the problem with the spinner?
– AnteGemini
Nov 15 '18 at 13:19
I did not fully understand the question, for is the problem with the spinner?
– AnteGemini
Nov 15 '18 at 13:19
@AnteGeminithe don't know if the problem is with spinner or the theme which is used in the application. But if you view those images i shared in the question you see clearly that in one device the selected spinner item is white while in another it is black. Yet both devices are running thesame app. Now my worry is that the spinner would not readable with it appears white
– N.Hubert
Nov 15 '18 at 15:31
@AnteGeminithe don't know if the problem is with spinner or the theme which is used in the application. But if you view those images i shared in the question you see clearly that in one device the selected spinner item is white while in another it is black. Yet both devices are running thesame app. Now my worry is that the spinner would not readable with it appears white
– N.Hubert
Nov 15 '18 at 15:31
@Ali please explain more
– N.Hubert
Nov 15 '18 at 15:39
@Ali please explain more
– N.Hubert
Nov 15 '18 at 15:39
add a comment |
1 Answer
1
active
oldest
votes
You can define inside your theme style for selected spinner value and for values in drop down list.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="spinnerItemStyle">@style/spinnerText</item>
<item name="spinnerDropDownItemStyle">@style/spinnerText</item>
</style>
<style name="spinnerText">
<item name="textColor">#000000</item>
</style>
More on this in this answer https://stackoverflow.com/a/21174361/1573414
this the error i got when I tried implementing the code: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found. Message{kind=ERROR, text=error: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found., sources=[/home/hubert/Hubert/app/src/main/res/values/styles.xml], original message=, tool name=Optional.of(AAPT)}
– N.Hubert
Nov 17 '18 at 19:34
I added "android" to all the item names as in <item name="android:spinnerItemStyle".. and it built and ran successfully but the issue of having white text in some devices persists
– N.Hubert
Nov 17 '18 at 19:46
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53318438%2fselected-item-in-spinner-is-white-in-android-versions-lowwer-or-equal-to-23%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can define inside your theme style for selected spinner value and for values in drop down list.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="spinnerItemStyle">@style/spinnerText</item>
<item name="spinnerDropDownItemStyle">@style/spinnerText</item>
</style>
<style name="spinnerText">
<item name="textColor">#000000</item>
</style>
More on this in this answer https://stackoverflow.com/a/21174361/1573414
this the error i got when I tried implementing the code: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found. Message{kind=ERROR, text=error: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found., sources=[/home/hubert/Hubert/app/src/main/res/values/styles.xml], original message=, tool name=Optional.of(AAPT)}
– N.Hubert
Nov 17 '18 at 19:34
I added "android" to all the item names as in <item name="android:spinnerItemStyle".. and it built and ran successfully but the issue of having white text in some devices persists
– N.Hubert
Nov 17 '18 at 19:46
add a comment |
You can define inside your theme style for selected spinner value and for values in drop down list.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="spinnerItemStyle">@style/spinnerText</item>
<item name="spinnerDropDownItemStyle">@style/spinnerText</item>
</style>
<style name="spinnerText">
<item name="textColor">#000000</item>
</style>
More on this in this answer https://stackoverflow.com/a/21174361/1573414
this the error i got when I tried implementing the code: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found. Message{kind=ERROR, text=error: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found., sources=[/home/hubert/Hubert/app/src/main/res/values/styles.xml], original message=, tool name=Optional.of(AAPT)}
– N.Hubert
Nov 17 '18 at 19:34
I added "android" to all the item names as in <item name="android:spinnerItemStyle".. and it built and ran successfully but the issue of having white text in some devices persists
– N.Hubert
Nov 17 '18 at 19:46
add a comment |
You can define inside your theme style for selected spinner value and for values in drop down list.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="spinnerItemStyle">@style/spinnerText</item>
<item name="spinnerDropDownItemStyle">@style/spinnerText</item>
</style>
<style name="spinnerText">
<item name="textColor">#000000</item>
</style>
More on this in this answer https://stackoverflow.com/a/21174361/1573414
You can define inside your theme style for selected spinner value and for values in drop down list.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="spinnerItemStyle">@style/spinnerText</item>
<item name="spinnerDropDownItemStyle">@style/spinnerText</item>
</style>
<style name="spinnerText">
<item name="textColor">#000000</item>
</style>
More on this in this answer https://stackoverflow.com/a/21174361/1573414
answered Nov 17 '18 at 7:04
AnteGeminiAnteGemini
7218
7218
this the error i got when I tried implementing the code: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found. Message{kind=ERROR, text=error: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found., sources=[/home/hubert/Hubert/app/src/main/res/values/styles.xml], original message=, tool name=Optional.of(AAPT)}
– N.Hubert
Nov 17 '18 at 19:34
I added "android" to all the item names as in <item name="android:spinnerItemStyle".. and it built and ran successfully but the issue of having white text in some devices persists
– N.Hubert
Nov 17 '18 at 19:46
add a comment |
this the error i got when I tried implementing the code: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found. Message{kind=ERROR, text=error: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found., sources=[/home/hubert/Hubert/app/src/main/res/values/styles.xml], original message=, tool name=Optional.of(AAPT)}
– N.Hubert
Nov 17 '18 at 19:34
I added "android" to all the item names as in <item name="android:spinnerItemStyle".. and it built and ran successfully but the issue of having white text in some devices persists
– N.Hubert
Nov 17 '18 at 19:46
this the error i got when I tried implementing the code: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found. Message{kind=ERROR, text=error: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found., sources=[/home/hubert/Hubert/app/src/main/res/values/styles.xml], original message=, tool name=Optional.of(AAPT)}
– N.Hubert
Nov 17 '18 at 19:34
this the error i got when I tried implementing the code: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found. Message{kind=ERROR, text=error: style attribute 'attr/spinnerItemStyle (aka com.example.android.hubert:attr/spinnerItemStyle)' not found., sources=[/home/hubert/Hubert/app/src/main/res/values/styles.xml], original message=, tool name=Optional.of(AAPT)}
– N.Hubert
Nov 17 '18 at 19:34
I added "android" to all the item names as in <item name="android:spinnerItemStyle".. and it built and ran successfully but the issue of having white text in some devices persists
– N.Hubert
Nov 17 '18 at 19:46
I added "android" to all the item names as in <item name="android:spinnerItemStyle".. and it built and ran successfully but the issue of having white text in some devices persists
– N.Hubert
Nov 17 '18 at 19:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53318438%2fselected-item-in-spinner-is-white-in-android-versions-lowwer-or-equal-to-23%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please I have looked at almost all the spinner related question and tried solutions like using a custom layout for spinner item or drop down list. But to no avail. I am not familiar with themes and how to tweak them to suite my needs. I just want the spinner to look presentable in all versions
– N.Hubert
Nov 15 '18 at 11:29
please look perfectly two images. background color change so i think you use different different theme for both.
– Ali
Nov 15 '18 at 11:33
I did not fully understand the question, for is the problem with the spinner?
– AnteGemini
Nov 15 '18 at 13:19
@AnteGeminithe don't know if the problem is with spinner or the theme which is used in the application. But if you view those images i shared in the question you see clearly that in one device the selected spinner item is white while in another it is black. Yet both devices are running thesame app. Now my worry is that the spinner would not readable with it appears white
– N.Hubert
Nov 15 '18 at 15:31
@Ali please explain more
– N.Hubert
Nov 15 '18 at 15:39