Open In App

Ferris Wheel in Android

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.



Application of Ferris Wheel

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.




<?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:


Article Tags :