3

App UI

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...

  • Do you want users to pick a number from those choices or its okay with you using EditText that accepts numbers only from 1 to 9. What language are you using to develop? – Xenolion Oct 19 '17 at 15:02
  • An Edit Text only fills up so much space on the screen, I have tried that already. I'd actually like them to choose a number. I'm using xml. – Adrian Breiding Oct 19 '17 at 15:15
  • May you should say how to you want it to be! – Xenolion Oct 19 '17 at 15:17
  • Basically I want some kind of menu, similar to the NumberPicker, which allows me to let the user choose one number. Perhaps even a ray of numbers and you can drag a pointer to a certain place and select one number. Is this understandable? – Adrian Breiding Oct 19 '17 at 15:27
  • May be you should consider visiting this question https://stackoverflow.com/questions/15031624/how-to-change-number-picker-style-in-android – Xenolion Oct 19 '17 at 16:15
  • Thanks a lot. That was helpful :) – Adrian Breiding Oct 20 '17 at 15:53
  • Okay! and **Happy Coding!** – Xenolion Oct 20 '17 at 16:55

2 Answers2

3

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.

Pory Sovann
  • 101
  • 2
1

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 .

Koen G.
  • 738
  • 5
  • 10