Hi,
I have this problem: I need my users to choose a number between 1 and 9, but the NumberPicker (as shown above) looks really ugly and all other alternatives aren't better. Do you have any alternatives?
Thanks a lot...
Hi,
I have this problem: I need my users to choose a number between 1 and 9, but the NumberPicker (as shown above) looks really ugly and all other alternatives aren't better. Do you have any alternatives?
Thanks a lot...
I used to have the same problem as your. And by default Android Component doesn't provide Horizontal NumberPicker.
So I used this one https://github.com/ShawnLin013/NumberPicker.
Hope it help in your case too.
It's not exactly compact, but as it is horizontal, it probably fits your layout better: https://github.com/blazsolar/HorizontalPicker
You have to define an array of strings in res/values/arrays.xml
for putting the items, like:
<array name="color_channel_values">
<item> "0" </item>
<item> "1" </item>
<item> "2" </item>
<item> "3" </item>
<item> "4" </item>
<item> "5" </item>
<item> "6" </item>
<item> "7" </item>
<item> "8" </item>
<item> "9" </item>
</array>
Also, to help visualizing the selection, a selector can be used for textColor
. Example res/color/horizontal_picker_selector.xml
:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:color="#ffffff" />
<item android:color="888888" />
</selector>
If you don't like that one, maybe you'll find something you like at https://android-arsenal.com/tag/142 .