Shimmer
Shimmer effect for Android
Support Ukraine 🇺🇦 Help Provide Humanitarian Aid to Ukraine
About

Shimmer is an Android library that provides an easy way to add a shimmer effect to any view in your Android app. It is useful as an unobtrusive loading indicator that was originally developed for Facebook Home.

Watch Introductory Video


Shimmer for Android is implemented as a layout, which means that you can simply nest any view inside a ShimmerFrameLayout tag, and call to start the animation from your code. That's all that is required. The layout will use the values you specify either on the tag (using custom attributes) or programmatically in your code, and generate an animation on the fly. See the API reference for further details.

Here's an example of a composite view, consisting of an image and some text below it, that shows the effect in action:

Download

To include Shimmer in your project, add the following dependency:

// Gradle dependency on Shimmer for Android
dependencies {
  implementation 'com.facebook.shimmer:shimmer:0.5.0'
}
    

  <!-- Maven dependency on Shimmer for Android -->
<dependency>
  <groupId>com.facebook.shimmer</groupId>
  <artifactId>shimmer</artifactId>
  <version>0.5.0</version>
</dependency>
    

Note that you cannot use the custom attributes on the tag if you use the Jar file. You can instead download the AAR file and reference that locally in your project.

Building

You can use the included Gradle wrapper to build the Shimmer library and sample application locally as well. Check out the code at github.com/facebook/shimmer-android.

# Install the latest code to your local repository
./gradlew shimmer:installArchives

# Install the sample app
./gradlew sample:installDebug
    
Usage

The following snippet shows how you can use ShimmerFrameLayout

<com.facebook.shimmer.ShimmerFrameLayout
     android:id="@+id/shimmer_view_container"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
>
     ...(your complex view here)...
</com.facebook.shimmer.ShimmerFrameLayout>
    

And thats it! If you specify `auto-start` to be false, then you can start the animation in code:

ShimmerFrameLayout container =
  (ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);
container.startShimmer(); // If auto-start is set to false
    
Attributes

You can control the look and pace of the effect using a number of custom attributes on the ShimmerFrameLayout tag. Alternatively, you can set these values on the layout object itself. For a comprehensive list, check out the API reference

Clip to Children
Whether to clip the shimmering effect to the children, or to opaquely draw the shimmer on top of the children. Use this if your overall layout contains transparency.
Colored
Whether you want the shimmer to affect just the alpha or draw colors on-top of the children.
Base Color
If colored is specified, the base color of the content.
Highlight Color
If colored is specified, the shimmer's highlight color.
Base Alpha
If colored is not specified, the alpha used to render the base view i.e. the unhighlighted view over which the highlight is drawn.
Highlight Alpha
If colored is not specified, the alpha of the shimmer highlight.
Auto Start
Whether to automatically start the animation when the view is shown, or not.
Duration
Time it takes for the highlight to move from one end of the layout to the other.
Repeat Count
Number of times of the current animation will repeat.
Repeat Delay
Delay after which the current animation will repeat.
Repeat Mode
What the animation should do after reaching the end, either restart from the beginning or reverse back towards it.
Direction
The travel direction of the shimmer highlight: left to right, top to bottom, right to left or bottom to top.
Dropoff
Controls the size of the fading edge of the highlight.
Intensity
Controls the brightness of the highlight at the center
Shape
Shape of the highlight mask, either with a linear or a circular gradient.
Tilt
Angle at which the highlight is tilted, measured in degrees
Fixed Width, Height
Fixed sized highlight mask, if set, overrides the relative size value
Width, Height ratio
Size of the highlight mask, relative to the layout it is applied to.
Support

Join the discussion over at our Facebook Group to report bugs, request features or show off your project.

Who is using Shimmer for Android?

Open an issue on Github if you are using this component in production and would like to be added to this list.

Slingshot
Slingshot uses Shimmer for Android to indicate loading status.


Home
Facebook Home uses the Shimmer effect to indicate status while loading the news feed, notifications and wallpaper settings.

License

Terms of Use

Privacy Policy

Copyright © Meta Platforms, Inc