Closed zsweigart closed 5 years ago
Do you need to have the image inside of the ShimmerFrameLayout
? Could you instead just hide the ShimmerFrameLayout
when you're done loading your image?
Shouldn't the ShimmerFrameLayout
contain the views? Or are you thinking of using RelativeLayout
or FrameLayout
parent view group that holds the shimmer and the image view and overlays them?
I was also able to achieve clearing by doing this:
shimmerFrameLayout.setShimmer(
new Shimmer.AlphaHighlightBuilder()
.setBaseAlpha(1)
.setIntensity(0)
.build());
shimmerFrameLayout.stopShimmer();
shimmerFrameLayout.clearAnimation();
But it's pretty ugly
Typically you have a "dummy" view inside of ShimmerFrameLayout
that takes the form of the content you expect to be shown. When your content is ready you remove the ShimmerFrameLayout
+ the "dummy" view and show your loaded content.
Interesting, I can give that a shot. I think this would be a nice enhancement to the API though. I'm using Picasso to load an image into my image view so it shimmers while the call is being made over the placeholder image. Then when the callback is either successful or a failure I clear the shimmer and show the image or the error image.
The appropriate use there would be to use a ShimmerDrawable
directly as the placeholder for Picasso while the image loads.
This used to be the case in 0.1.0 where calling stopShimmerAnimation() would remove the overlay completely. This was useful when there is content already on the screen which is being "reloaded", or the user performs an action that requires additional loading. In cases like this I don't want to replace preexisting content with a dummy view.
It seems like a good compromise is letting users call setShimmer(null)
to remove the shimmer. I can make that change.
e7a2129f79a6d2c76fceddaf1a8c401e30b4f5b8
@xiphirx any word on release with this change?
0.4.0 was just pushed to sonatype.
Shouldn't the
ShimmerFrameLayout
contain the views? Or are you thinking of usingRelativeLayout
orFrameLayout
parent view group that holds the shimmer and the image view and overlays them?I was also able to achieve clearing by doing this:
shimmerFrameLayout.setShimmer( new Shimmer.AlphaHighlightBuilder() .setBaseAlpha(1) .setIntensity(0) .build()); shimmerFrameLayout.stopShimmer(); shimmerFrameLayout.clearAnimation();
But it's pretty ugly
Nice workaround, also using setShimmer(null)
much cleaner~
Old issue, but what if you want to remove the shimmer and then show it later, e.g. refreshing a page? Does setShimmer(null)
mean you will have to rebuild the Shimmer
instance from scratch?
You can use the new show/hide methods https://github.com/facebook/shimmer-android/commit/97ca4d1d7cd1ec4e3435ee46a1748da00aa0511e
@xiphirx Can you cut a new release?
https://github.com/facebook/shimmer-android/releases/tag/0.5.0
Give it a few minutes to propagate to maven central
When I am using shimmer.stopShimmer(); my app is force stoped. shimmer is working in loop on my project.
How can i stop it.
what happens to shimmer when onDestroy() is called after starting the animation? deos it destroy itself or does it need to be handled manually
You can use the new show/hide methods 97ca4d1
thank you so much ! it helped.
Shouldn't the
ShimmerFrameLayout
contain the views? Or are you thinking of usingRelativeLayout
orFrameLayout
parent view group that holds the shimmer and the image view and overlays them?I was also able to achieve clearing by doing this:
shimmerFrameLayout.setShimmer( new Shimmer.AlphaHighlightBuilder() .setBaseAlpha(1) .setIntensity(0) .build()); shimmerFrameLayout.stopShimmer(); shimmerFrameLayout.clearAnimation();
But it's pretty ugly
where we use this code and what we write inside .placeholder in glide library
I have an image view inside a shimmer frame layout, when load an image into the image view I want to clear the shimmer entirely but there is no way to do this. If I stop the shimmer there is still an overlay over my image view.