Questions tagged [shimmer]

Shimmer for Android 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, and was originally developed for Facebook Home.

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.

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.

Download

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

// Gradle dependency on Shimmer for Android
dependencies {
  implementation 'com.facebook.shimmer:shimmer:x.x.x'
}
//Replace xxx with version


<!-- Maven dependency on Shimmer for Android -->
<dependency>
  <groupId>com.facebook.shimmer</groupId>
  <artifactId>shimmer</artifactId>
  <version>x.x.x</version>
</dependency>
//Replace xxx with version

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.

34 questions
20
votes
3 answers

How to use a view (shimmer) as a placeholder for an imageView (Glide)

I am using Glide to load images to my imageView (which are inside a recyclerview): Glide.with(image.context).load(url) .error(context.getDrawable(R.drawable.placeholder)) .into(image) I see that the Glide library also has a…
Mehdi Satei
  • 1,225
  • 9
  • 26
4
votes
1 answer

Shimmer animation in vector drawable

Ive been trying to achieve a shimmer animation for an icon using animation vector drawable. The effect that I'm looking for is something similar to this- I have used the FaceBook shimmer library to get this effect, and even though this is exactly…
Anirudh
  • 2,080
  • 5
  • 21
  • 34
4
votes
1 answer

How to get shimmer effect like facebook in flutter?

I am trying to create a video streaming app and want shimmer effect like facebook, any suggestion how to get it?
Parag Singh
  • 81
  • 1
  • 5
4
votes
2 answers

How do I set the shimmer layout duration programmatically in java?

I want to set the shimmer layout duration programmatically in Java. I have done it in xml, it works, but I want to do it in Java. Here is the xml code:
David Kariuki
  • 1,522
  • 1
  • 15
  • 30
4
votes
1 answer

Android Vertical Shimmer

While navigating through Android Material Components, I came across this list loading animation. I know a few libraries (e.g.ShimmerLayout, Facebook's Shimmer) which have horizontal loading animation. But it is not as smooth since it just renders…
Rajkiran
  • 15,845
  • 24
  • 74
  • 114
3
votes
0 answers

Facebook Shimmer library with Paging 3 library

In my app I load data from API which is using paginating so I have to use paging 3 library and I use facebook shimmer library to show shimmer effect when items are being loaded but the problem is always shimmer effect is shown even when items are…
amir215909
  • 139
  • 8
3
votes
0 answers

Android Studio ShimmerFrameLayout preview not working correctly after v0.2.0 in Design View

I'm using Facebook ShimmerFrameLayout in my app. But It is not rendering correctly after upgrading from v0.1.0 to v0.5.0. It is showing a gray color box instead of actual elements inside the layout. Does anyone know any reason for that and any…
Chathura Buddhika
  • 2,067
  • 1
  • 21
  • 35
3
votes
1 answer

Shimmer layout api 19

I'd like to know why is my shimmer layout black when api is 19, when it's more than 19 it displays as white(the color it should be). API 19 --------------------------------------- API >=20
Darthcow
  • 358
  • 4
  • 14
2
votes
0 answers

ShimmerAndroidInstrumentDrive API error No variants found for ':app', help please

I have a basic application that renders a 3d model. Now I need to connect to the Shimmer Inertial Measurement Units via bluetooth. I have added the ShimmerAndroidInstrumentDriver folder to my libs folder in the root directory of my project and added…
2
votes
2 answers

Flutter skeleton view shimmer view

I'm trying to achieve the skeleton view as shown in the attachment but couldn't get it exactly like shown, i have tried Shimmer package, the problem is gradient or mask width is more. Kindly help with sample for to achieve the same. Used the…
pAr
  • 171
  • 1
  • 16
2
votes
1 answer

Rounded shimmerDrawable (facebook android-shimmer)

So, i have drawable from https://github.com/facebook/shimmer-android val shimmer = ColorHighlightBuilder() .setBaseColor(ContextCompat.getColor(context, R.color.skeleton_mask)) .setBaseAlpha(SHIMMERING_BASE_ALPHA) …
Efimov Aleksandr
  • 165
  • 2
  • 12
2
votes
1 answer

How to distinguish between initial load and content change in Android Paging 3?

I have a RecyclerView that uses a PagingDataAdapter to show its items. On initial load of the entire page, I want to show a Shimmer loading placeholder. However, when I try to do this, the loading placeholder also shows up for a small content change…
Eva
  • 4,397
  • 5
  • 43
  • 65
2
votes
1 answer

How do I set the layout for ShimmerLayout programmatically in Kotlin?

NOTE: My question is different from this. I want to set the layout of ShimmerLayout programmatically in Kotlin code. Is that possible to do? Currently, I can set the layout via XML like this:
R Rifa Fauzi Komara
  • 1,915
  • 6
  • 27
  • 54
1
vote
0 answers

Shimmer effect causes Exception on rebuilds in Flutter

I followed the official tutorial by the Flutter team for creating a shimmer effect: Create a shimmer loading effect I copied most of the code into a file and updated some lines with e.g. custom colors: LinearGradient scGradient(BuildContext context)…
Florian Leeser
  • 590
  • 1
  • 6
  • 20
1
vote
0 answers

Android facebook shimmerFrameLayout set reapeat delay not working correctly?

I use ShimmerFrameLayout in the android project. When i set app:shimmer_repeat_delay="integer" in XML layout file, that changes shimmer_duration(shimmer sweep slowly!). Is this a bug? Does someone have a solution? Thanks for your help. library url:…
Saeid Z
  • 387
  • 3
  • 17
1
2 3