在我的布局中添加一个小的Numberpicker
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在我的布局中添加一个小的Numberpicker相关的知识,希望对你有一定的参考价值。
答案
我曾经和你有同样的问题。默认情况下,android Component不提供Horizontal NumberPicker。 所以我用了一个https://github.com/ShawnLin013/NumberPicker。 希望它对你的情况也有帮助。
另一答案
它不是很紧凑,但因为它是水平的,它可能更适合你的布局:https://github.com/blazsolar/HorizontalPicker
您必须在res/values/arrays.xml
中定义一个字符串数组来放置项目,例如:
<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>
此外,为了帮助可视化选择,选择器可用于textColor
。示例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>
如果你不喜欢那个,也许你会在https://android-arsenal.com/tag/142找到你喜欢的东西。
以上是关于在我的布局中添加一个小的Numberpicker的主要内容,如果未能解决你的问题,请参考以下文章
Android NumberPicker OnValueChangeListener