How to add floating label on Spinner

前端 未结 10 1730
Happy的楠姐
Happy的楠姐 2020-12-12 14:46

After using the Android Design Support Library\'s TextInputLayout to place a floating label above an EditText component, I was wondering if there is a way to add a floating

10条回答
  •  星月不相逢
    2020-12-12 15:20

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

提交回复
热议问题