() An Android TextView with a shimmering effect

Overview

Shimmer for Android

This library is DEPRECATED, as I don't have time to mainatin it anymore. But feel free to go through the code and copy that into your project, it still does its job.

Shimmer-android is an Android port of Facebook Shimmer library for iOS.

ScreenShot

http://youtu.be/7EOsegp4J2o

Examples of usage:

  • show a loading indicator
  • show a highlighted TextView.

How to use

Gradle dependency:

compile 'com.romainpiel.shimmer:library:1.4.0@aar'

Add a ShimmerTextView to your layout:

<com.romainpiel.shimmer.ShimmerTextView
    android:id="@+id/shimmer_tv"
    android:text="@string/shimmer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#444"
    android:textSize="50sp"/>

To start the animation:

shimmer = new Shimmer();
shimmer.start(myShimmerTextView);

You may want to keep track of the shimmer instance after the animation is started if you want to stop it.

To stop it:

shimmer.cancel();

Customization

Customizing the view

You can change the color of the reflection using the custom attribute reflectionColor:

<com.romainpiel.shimmer.ShimmerTextView
    android:id="@+id/shimmer_tv"
    android:text="@string/shimmer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#444"
    android:textSize="50sp"
    app:reflectionColor="#f00"/>

Customizing the animation

The animation can be tweaked like a usual ObjectAnimator:

// DON'T COPY THIS CODE TO YOUR PROJECT! It is just an example
shimmer.setRepeatCount(0)
    .setDuration(500)
    .setStartDelay(300)
    .setDirection(Shimmer.ANIMATION_DIRECTION_RTL)
    .setAnimatorListener(new Animator.AnimatorListener(){});

Custom Shimmer view

Shimmer also includes a ShimmerButton. It works exactly the same way as a ShimmerTextView. Have a look at how it's implemented and you can apply the same effect on your custom view if you need it.

Sample

See the sample for a common use of this library.

License

Copyright 2014 Romain Piel

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • app icon conflict

    app icon conflict

    android:icon="@drawable/ic_launcher"

    My app icon turns into 'ic_launcher.png' of the shimmer library on Nexus 5(Android 5.1).But on the other phones Android 4.+ it's my 'ic_launcher.png'. How to fix ? change my icon file name ?

    opened by ff0o0 7
  • LinearGradient cache/postInvalidateOnAnimation

    LinearGradient cache/postInvalidateOnAnimation

    Just my ¢2

    • Most of the time is a bad idea to have new in your draw methods, you'd get a bunch of jank as they are called often specially on animation, and currently there are three of them at LinearGradientFactory#resize method, given that Shaders are immutable, would you consider using a LRU cache?
    • For 16+ onAnimationEnd consider using postInvalidateOnAnimation instead of postInvalidate
    opened by eveliotc 7
  • added onSizeChanged() in Button/TextView to make sure the LinearGradient will be reset

    added onSizeChanged() in Button/TextView to make sure the LinearGradient will be reset

    Hi, I added onSizeChanged() in both Button and TextView components to make sure the ineargradient property will be reset properly.

    If the Button/TextView changed visibility from GONE to VISIBLE, should call resetLinearGradient() again.

    opened by Keanu 4
  • Added support for right-to-left shimmer

    Added support for right-to-left shimmer

    Hey there!

    Nice library. I just added another styleable attribute called shimmerDirection to let the user decide the direction of the shimmer movement. It works just like LinearLayout's "layoutDirection" attribute.

    opened by mattlogan 4
  • RTL Shade?

    RTL Shade?

    I took a quick look into the source code. It seems that the magic is happening in LinearGradientFactory. is it possible to customize the class to supports shades going from right to left? This would be great if you consider RTL languages.

    opened by iturki 3
  • NoSuchMethod Exception setGradientX() when use proguard

    NoSuchMethod Exception setGradientX() when use proguard

    https://github.com/RomainPiel/Shimmer-android/blob/master/library/src/main/java/com/romainpiel/shimmer/Shimmer.java

    animator = ObjectAnimator.ofFloat(shimmerView, "gradientX", fromX, toX);

    Using reflection in this method throws NoSuchMethod Exceptopm when build by proguard. add -keep class com.shimmer.{;}" and fix the problem.

    opened by changety 1
  • Got crash when running demo on android 4.2 device

    Got crash when running demo on android 4.2 device

    04-12 17:36:45.171: E/AndroidRuntime(20959): Caused by: java.lang.NoClassDefFoundError: com.romainpiel.shimmer.R$styleable 04-12 17:36:45.171: E/AndroidRuntime(20959): at com.romainpiel.shimmer.ShimmerViewHelper.init(ShimmerViewHelper.java:111) 04-12 17:36:45.171: E/AndroidRuntime(20959): at com.romainpiel.shimmer.ShimmerViewHelper.(ShimmerViewHelper.java:56) 04-12 17:36:45.171: E/AndroidRuntime(20959): at com.romainpiel.shimmer.ShimmerTextView.(ShimmerTextView.java:30)

    opened by yorkwang 1
  • Some issue with 1.4.0

    Some issue with 1.4.0

    AAPT: /home/debugger22/AndroidStudioProjects/PlaceboButton/app/build/intermediates/exploded-aar/com.romainpiel.shimmer/library/1.4.0/res/drawable-nodpi-v4/spot_mask.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
    
    opened by debugger22 0
  • removed allowBackup flag

    removed allowBackup flag

    allowBackup flag shouldn't be used in libraries due to build problems: https://code.google.com/p/android/issues/detail?id=70073 https://github.com/chrisbanes/PhotoView/issues/199

    opened by soniccat 0
  • unable to run

    unable to run

    with error FATAL EXCEPTION: main Process: com.trifidresearch.trifidresearch, PID: 4843 java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.romainpiel.shimmer.ShimmerViewBase.isSetUp()' on a null object reference at com.romainpiel.shimmer.Shimmer.start(Shimmer.java:150) at com.trifidresearch.trifidresearch.Home$5.onResponse(Home.java:215) at com.trifidresearch.trifidresearch.Home$5.onResponse(Home.java:191) at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60) at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30) at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

    opened by ameetpawar00 0
  • build failed

    build failed

    Error:Execution failed for task ':app:processDevDebugResources'.

    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/Cellar/android-sdk/24.2/build-tools/22.0.1/aapt'' finished with non-zero exit value 1

    opened by xcqwan 3
  • Doesn't work on 5.1 +

    Doesn't work on 5.1 +

    The shimmer animation doesnt work on android 5.1+

    ive tested on my moto g running 5.1 and nexus 5 running 6,

    it runs properly on ym samsung kitkat device

    opened by vnh1991 1
Owner
Romain Piel
Romain Piel
A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds.

SecretTextView A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds. How To Use Use it just l

Matt Kula 611 Nov 7, 2022
() Android experiment showing a sinking TextView

Titanic for Android This library is DEPRECATED, as I don't have time to mainatin it anymore. But feel free to go through the code and copy that into y

Romain Piel 1.8k Dec 15, 2022
Android's TextView that can expand/collapse like the Google Play's app description

ExpandableTextView ExpandableTextView is an Android library that allows developers to easily create an TextView which can expand/collapse just like th

Manabu S. 4k Jan 8, 2023
This is based on an open source autosizing textview for Android.

SizeAdjustingTextView This is based on an open source autosizing textview for Android I found a few weeks ago. The initial approach didn't resize mult

Elliott Chenger 255 Dec 29, 2022
A TextView that automatically resizes text to fit perfectly within its bounds.

AutoFitTextView A TextView that automatically resizes text to fit perfectly within its bounds. Usage dependencies { compile 'me.grantland:autofitt

Grantland Chew 4.2k Jan 8, 2023
:page_facing_up: Android Text Full Jusiftication / Wrapping / Justify / Hyphenate - V2.0

LIBRARY IS NO LONGER MAINTAINED If you want to adopt + maintain this library, please drop me a message - [email protected] Android Full Justific

Mathew Kurian 1.9k Dec 29, 2022
RoundedLetterView like the one in Android 5.0 Contacts app

RoundedLetterView RoundedLetterView like the one in Android 5.0 Contacts app Attributes to choose from: rlv_titleText - The text in the first row. rlv

Pavlos-Petros Tournaris 653 Nov 11, 2022
A editable text with a constant text/placeholder for Android.

ParkedTextView A EditText with a constant text in the end. How to use <com.goka.parkedtextview.ParkedTextView xmlns:app="http://schemas.android.co

goka 270 Nov 11, 2022
Android Library to make it easy to create CodeEditor or IDE that support any languages and themes

CodeView Android Library to make it easy to create your CodeEditor or IDE for any programming language even for your programming language, just config

Amr Hesham 294 Jan 6, 2023
() An Android TextView with a shimmering effect

Shimmer for Android This library is DEPRECATED, as I don't have time to mainatin it anymore. But feel free to go through the code and copy that into y

Romain Piel 2k Jan 7, 2023
An easy, flexible way to add a shimmering effect to any view in an Android app.

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 a

Facebook 5.1k Dec 31, 2022
An easy, flexible way to add a shimmering effect to any view in an Android app.

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 a

Facebook 5.1k Dec 26, 2022
Memory efficient shimmering effect for Android applications by Supercharge.

DEPRECATED - ShimmerLayout Attention: This tool is now deprecated. Please switch to Shimmer for Android or any other shimmer effect solution. ShimmerL

Supercharge 2.5k Jan 4, 2023
:performing_arts: An easy, flexible way to implement veil skeletons and shimmering effect for Android.

AndroidVeil An easy, flexible way to implement veil skeletons and shimmering effect for Android. Download Gradle Add below codes to your root build.gr

Jaewoong Eum 1.2k Dec 28, 2022
A simple and flexible Checked TextView or Checkable TextView

CheckableTextView Checkable TextView [KOTLIN] ⚡ A simple and flexible Checked TextView or Checkable TextView written in Kotlin ⚡ What's New Animation

null 110 Nov 20, 2022
Mentions-TextView - Make Mentions and hashtags clickable in Textview

Mentions Textview Custome Textview with Mentions and hashtags being clickable. D

null 2 Jan 9, 2022
:ribbon: The simple way to implement a beautiful ribbon with the shimmering on Android.

AndroidRibbon ?? The simple way to implement a beautiful ribbon with the shimmering on Android. 中文語 Download Gradle Add below codes to your root build

Jaewoong Eum 653 Jan 7, 2023
A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds.

SecretTextView A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds. How To Use Use it just l

Matt Kula 611 Nov 7, 2022
A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds.

SecretTextView A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds. How To Use Use it just l

Matt Kula 611 Nov 7, 2022
ShimmerTextView is a simple library to integrate shimmer effect in your TextView.

ShimmerTextView ShimmerTextView is a simple library to integrate shimmer effect in your TextView. Key features Set a base color in ShimmerTextView. Se

MindInventory 22 Sep 7, 2022