How to create Rotating Text in android | Android Studio | Java

Part 1: Add Dependency

Part 2: Example 1 (Simple rotating effect)

In the main XML file creates a Rotating text wrapper.

  • In the main java file defines the two main parts of the Rotating Text i.e. RotatingTextWrapper and Rotatable.
  • In RotatingTextWrapper defines the actual layout of the text and the positions of the rotating text.
  • And in the Rotatable, we define the rotating text properties, such as color, size, typeface, interpolator, update duration, animation duration, and center align. Below we will discuss these properties.

Now in the main java file

Preview

Part 2: Example 2 (Typeface + Interpolator)

In the main XML file

In the main java file

Preview

Part 3: Documentation

RotatingTextWrapper

  • Content (setContent(..)): set the actual content. Compose of a String and array of Rotatable.
  • Typeface (setTypeface(..)): Set the typeface of the non-ratating text
  • Size (setSize(..)): set the size of the non-rotating text.
  • Pause (pause(x)): Method to pause the ‘x’th rotatable.
  • Resume (resume(x)): Method to resume the ‘x’th rotatable.

Rotatable

  • Color (setColor(..)): set the color of the rotating text associated with this rotatable.
  • Size (setSize(..)): set the size of the rotating text associated with this rotatable
  • Typeface (setTypeface(…)): Set the typeface of the rotating text associated with this rotatable
  • Interpolator (setInterpolator(..)): Set the animation interpolator used while switching text
  • Update Duration (setUpdateDuration(..)): Set the interval between switching the words
  • Animation Duration (setAnimationDuration(..)): Set the duration of the switching animation
  • Center Align (setCenter(..)): Align the rotating text to the center of the textview if set to true

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Golap Gunjan Barman

Golap Gunjan Barman

Hi everyone, myself Golap an Android app developer with UI/UX designer.