Skip to content
Related Articles

Related Articles

Improve Article

Ferris Wheel in Android

  • Last Updated : 23 Feb, 2021

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

Want a more fast-paced & competitive environment to learn the fundamentals of Android?
Click here to head to a guide uniquely curated by our experts with the aim to make you industry ready in no time!

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_cabinsNumberUse to give the number of cabins on the wheel. 
fwv_isAutoRotateThe Wheel rotates automatically. 
fwv_isClockwiseThe Wheel rotates in a clockwise direction. 
fwv_rotateSpeedUse to give wheel rotation speed. 
fwv_cabinSizeUse to determine the size of the cabin. 
fwv_cabinFillColorUse to give color to each cabin. 
fwv_startAngleThe angle at which the wheel starts rotating. 
fwv_wheelStrokeColorTo give color to the wheel. 
fwv_cabinLineStrokeColorCabin 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:




My Personal Notes arrow_drop_up
Recommended Articles
Page :