Material Spinner
Material Spinner which looks like EditText inside TextInputLayout
Example
Usage
Step 1: Add MaterialSpinner
in XML
<io.pravikant.materialspinner.MaterialSpinner
android:id="@+id/main_occupation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ms_hint="Occupation" />
Step 2: Set items
main_occupation.setItems(resources.getStringArray(R.array.occupations))
Step 3: Get current selected item
main_occupation.getSelectedItem().toString()
Custom ArrayAdapter
val adapter = ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, resources.getStringArray(R.array.occupations))
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
main_occupation.setAdapter(adapter)
Attributes
<attr name="ms_hint" format="string" />
<attr name="ms_hint_color" format="color" />
<attr name="ms_line_color" format="color" />
<attr name="ms_text_size" format="dimension" />
Download
Gradle:
repositories {
mavenCentral()
google()
}
dependencies {
implementation 'io.pravikant:materialspinner:1.0.0'
}
Note: Don't forget to add mavenCentral()
under repositories
in root-level build.gradle
Maven:
<dependency>
<groupId>io.pravikant</groupId>
<artifactId>materialspinner</artifactId>
<version>1.0.0</version>
<type>aar</type>
</dependency>
Author
Pramod Ravikant
Licence
This project is licensed under the MIT License - see the LICENSE file for details