如何使用浮动文本自定义微调器
How to customize a spinner with floating text
我想使用浮动文本自定义 Spinner
,就像 EditText
中的浮动标签一样。请查看下面的参考图片:
现在我想把 TextView
放在 Spinner
的正上方,这样它看起来就像图像中那样。如果我说错了或者大家有不同意见请帮助我。
更新
解决方案:使用以下库在 pre-lollipop 上使用 material 主题
https://github.com/rey5137/material
正如我在 this answer to my own question 中所写...
I have created a compound View
component which displays a label above the Spinner
. The text for the label can be set using XML or in Java.
The component has the key features of a Spinner
(not all of them) as well as looking similar to the TextInputLayout
component.
I have named it a LabelledSpinner
, and it is available as part of my UsefulViews Android library on GitHub under the Apache 2.0 License.
To use it, add the library dependency in your build.gradle
file:
compile 'com.satsuware.lib:usefulviews:+'
Examples of its usage are available at the GitHub repository (both a sample app, and a usage guide).
我想使用浮动文本自定义 Spinner
,就像 EditText
中的浮动标签一样。请查看下面的参考图片:
现在我想把 TextView
放在 Spinner
的正上方,这样它看起来就像图像中那样。如果我说错了或者大家有不同意见请帮助我。
更新
解决方案:使用以下库在 pre-lollipop 上使用 material 主题 https://github.com/rey5137/material
正如我在 this answer to my own question 中所写...
I have created a compound
View
component which displays a label above theSpinner
. The text for the label can be set using XML or in Java.The component has the key features of a
Spinner
(not all of them) as well as looking similar to theTextInputLayout
component.I have named it a
LabelledSpinner
, and it is available as part of my UsefulViews Android library on GitHub under the Apache 2.0 License.To use it, add the library dependency in your
build.gradle
file:
compile 'com.satsuware.lib:usefulviews:+'
Examples of its usage are available at the GitHub repository (both a sample app, and a usage guide).