--ADVERTISEMENT--

Android spinner allows us to select an item from dropdown menu. Many android applications have used spinner component in their application. In this tutorial, you will learn to implement material design spinner component (dropdown menu) in your application.

You can display spinner where you want using XML or java. Here we work with both XML and java code. Implementing material design spinner in android application is not much difficult; you can just add it with little bit XML and java code.

Related:
Android Drop Down List Example
Simple Android Spinner Example
Android Custom Vertical Dropdown Icons Menu

Android Example: How to Make Material Design Android Spinner


To implement material design spinner first you have to add a dependency compile 'com.weiwangcn.betterspinner:library-material:1.1.0' in your project build.gradle file. Your build.gradle file somehow looks like below.

build.gradle

XML Layout File

In XML layout file you need to add material design spinner inside a layout like LinearLayout, RelativeLayout. Following is the complete content of XML layout file, you can paste it in yout project XML layout file.

res/layout/android_material_design_spinner.xml

Java Activity File

In java activity file, you need to add some strings for dropdown option list and link them to the spinner. Following is the complete code of java activity file; you can directly paste it in your project java activity file.

src/AndroidMaterialSpinner.java

Android Example: How to Make Material Design Android Spinner

Run your Android Material Design Spinner DropDown Example application and click on the dropdown option which will look like above screenshot.

Post a Comment

Powered by Blogger.