Open In App

Ferris Wheel in Android

Improve
Improve
Like Article
Like
Save
Share
Report

Building 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 see how to implement the Ferris Wheel in Android. Below is a sample GIF of the Ferris Wheel.

Ferris Wheel in Android

Application of Ferris Wheel

  • Ferris Wheel is a unique way of representing data or various options.
  • This Ferris Wheel is used in most of the games built for children to learn to count, alphabets in animated form. So that small children can gain interest in it.
  • You can see this Ferris Wheel in the spin wheel game to earn rewards.
  • This Ferris wheel can also be used to represent various options in circular list form.

Attributes of Ferris Wheel

Attribute

Description

fwv_cabinsNumber Use to give the number of cabins on the wheel. 
fwv_isAutoRotate The Wheel rotates automatically. 
fwv_isClockwise The Wheel rotates in a clockwise direction. 
fwv_rotateSpeed Use to give wheel rotation speed. 
fwv_cabinSize Use to determine the size of the cabin. 
fwv_cabinFillColor Use to give color to each cabin. 
fwv_startAngle The angle at which the wheel starts rotating. 
fwv_wheelStrokeColor To give color to the wheel. 
fwv_cabinLineStrokeColor Cabin lines will be filled with colors. 

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 of the library in build.gradle file

Navigate to gradle scripts and then to build.gradle(Module) level. Add below line in build.gradle file in the dependencies section.

implementation ‘ru.github.igla:ferriswheel:1.2’

After adding dependency click on the “sync now” option on the top right corner to sync the project.

Step 3: Working with the activity_main.xml file

Go to the activity_main.xml file and refer to the following code. Below is the code for the activity_main.xml file.

Java




<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
  
    <ru.github.igla.ferriswheel.FerrisWheelView
        android:id="@+id/ferrisWheelView"
        android:layout_width="300dp"
        android:layout_centerInParent="true"
        android:layout_height="300dp"
        android:layout_gravity="center"
        app:fwv_cabinsNumber="8"
        app:fwv_rotateSpeed="10" />
  
</RelativeLayout>


Output:



Last Updated : 23 Feb, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads