Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • DSA Tutorial
  • Data Structures
  • Algorithms
  • Array
  • Strings
  • Linked List
  • Stack
  • Queue
  • Tree
  • Graph
  • Searching
  • Sorting
  • Recursion
  • Dynamic Programming
  • Binary Tree
  • Binary Search Tree
  • Heap
  • Hashing
  • Divide & Conquer
  • Mathematical
  • Geometric
  • Bitwise
  • Greedy
  • Backtracking
  • Branch and Bound
  • Matrix
  • Pattern Searching
  • Randomized
Open In App
Next Article:
WheelView in Android
Next article icon

WheelView in Android

Last Updated : 30 Apr, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, WheelView is added in android. WheelView provides a very impressive UI that allows the developer to create a Wheel and add items according to his need. Some important tags provided by WheelView are wheelArcBackgroundColor, wheelAnchorAngle, wheelStartAngle, wheelMode, wheelCenterIcon, and many more. It can be used where the user wants to select items from a list of items. Suppose in the banking app, the user has the option to select its bank account to check balance, payment history, etc in that case this can be used.

Advantages:  

  • It can be customized according to the requirements.
  • It provides animation with the view which improves the User Interface.
  • It provides an inbuilt layout that its alternatives like Custom Dialog which can be used instead of wheel view does not provide.

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.

Step 2: Add dependency and JitPack Repository

Navigate to the Gradle Scripts > build.gradle(Module:app) and add the below dependency in the dependencies section.   

implementation 'com.github.psuzn:WheelView:1.0.1'

Add the JitPack repository to your build file. Add it to your root build.gradle at the end of repositories inside the allprojects{ } section.

allprojects {

 repositories {

   ...

   maven { url "https://jitpack.io" }

     }

}

After adding this dependency sync your project and now we will move towards its implementation.  

Step 3: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. 

XML
<androidx.constraintlayout.widget.ConstraintLayout     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent">       <me.sujanpoudel.wheelview.WheelView         android:id="@+id/wheel_view"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_margin="16dp"         app:wheelDividerStrokeWidth="16dp"         app:wheelArcBackgroundColor="#F7F8FB"         app:wheelSelectedArcBackgroundColor="@color/colorPrimary"         app:wheelCenterIcon="@drawable/ic_baseline_add_24"         app:wheelCenterIconPadding="16dp"         app:wheelCenterIconTint="@android:color/white"         app:wheelAnchorAngle="270"         app:wheelStartAngle="315"         app:wheelTextSize="16sp"         app:wheelSelectedTextColor="#FFF"         app:wheelTextColor="#000000"         app:wheelAnimationDuration="800"         app:wheelMode="ANIMATE_TO_ANCHOR"         />   </androidx.constraintlayout.widget.ConstraintLayout>  

Step 4: Working with the MainActivityfile

Go to the MainActivity file and refer to the following code. Below is the code for the MainActivity file. Comments are added inside the code to understand the code in more detail.

Java
import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import java.util.Arrays; import me.sujanpoudel.wheelview.WheelView;  public class MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          // create a string array  of tiles         String[] titles={"Bubble Sort", "Quick Sort", "Merge Sort", "Radix Sort"};                  // get the reference of the wheelView         WheelView wheelView =(WheelView)findViewById(R.id.wheel_view);          // convert tiles array to list and pass it to setTitles          wheelView.setTitles(Arrays.asList(titles));     } } 
Kotlin
import androidx.appcompat.app.AppCompatActivity  import android.os.Bundle  import me.sujanpoudel.wheelview.WheelView   class MainActivity : AppCompatActivity() {      override fun onCreate(savedInstanceState: Bundle?) {          super.onCreate(savedInstanceState)          setContentView(R.layout.activity_main)           val wheelView = findViewById<WheelView>(R.id.wheel_view)          wheelView.titles = listOf("Bubble Sort", "Quick Sort", "Merge Sort", "Radix Sort")      }  }  

Output: 


Next Article
WheelView in Android

M

madhavmaheshwarimm20
Improve
Article Tags :
  • Kotlin
  • Android
  • DSA
  • Android-View

Similar Reads

    PopView in Android
    In this article, PopView is added to android. When users tap on the view a pop animation with a circular dust effect will appear. A new view can also appear after the popping of the older view. PopView can be used to hide the view or change the view. It makes the user interface more attractive. Supp
    3 min read
    Ferris Wheel in Android
    Building a Ferris Wheel in Android is another best thing to do for beginner Android developers. With the help of dependency, you can be able to create the Ferris Wheel. Ferris Wheel is an Android library that is a unique way to represent data in the Animated form. In this article, we are going to se
    2 min read
    Zigzag View in Android
    Zigzag View is a unique UI element that enhances the user experience in Android applications. You can often find this design element in eCommerce apps, where it makes the existing interface unique. The main purpose of Zigzag View is to create eye-catching banner ads or to display images and text in
    2 min read
    Android View Shaker in Kotlin
    View Shaker is an android animation in which the UI of the screen vibrates for a specific interval of time. We can implement this View shaker to the specific views of the application. View Shaker provides different animation effects which we can add to our views such as bounce, fade, float, and othe
    4 min read
    Zoom Scroll View in Android
    In this article, we are going to implement Zoom on ScrollView. Most of the time when we create a scroll view then it contains a lot of data and if we want to view any content on zooming then we can implement this feature. This feature can be useful when we are scrolling in an App and that contains d
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences