() 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
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
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'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 Dec 28, 2022
A library to show emoji in TextView, EditText (like WhatsApp) for Android

Discontinued This projected is discontinued. Please consider using other alternative, i.e EmojiCompat. Contact me if you want to continue working on a

Hieu Rocker 3.6k Jan 5, 2023
Android experiment showing a sinking TextView

Titanic is an Android experiment reproducing this effect.

Romain Piel 1.8k Dec 15, 2022
Advanced Android TextView

Advanced Android TextView Companion app for my Advanced Android TextView talk, demostrating: Animated CompoundDrawable Text shadow Custom font Non-bre

Chiu-Ki Chan 1.2k Dec 9, 2022
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
An extension of Android's TextView, EditText and Button that let's you use the font of your choice

AnyTextView (deprecated) Note: AnyTextView is no longer being maintained. I recommend replacing AnyTextView with the Calligraphy library instead. Frus

Hans Petter Eide 165 Nov 11, 2022
Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies.

android-formidable-validation Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Pr

Linden 147 Nov 20, 2022
Simple way to create linked text, such as @username or #hashtag, in Android TextView and EditText

Simple Linkable Text Simple way to create link text, such as @username or #hashtag, in Android TextView and EditText Installation Gradle Add dependenc

Aditya Pradana Sugiarto 76 Nov 29, 2022
Lightweight android library for highlighting sections of a textview, with optional callbacks.

Linker Lightweight android library for highlighting Strings inside of a textview (ignoring case), with optional callbacks. Language: Java MinSDK: 17 J

Josh Gainey 35 Apr 30, 2022
Android slanted TextView.

SlantedTextView Android slanted TextView . 中文版 Preview Gradle compile 'com.haozhang.libary:android-slanted-textview:1.2' XML Layout <com.haozhang.lib.

Hand Zhang 2.2k Dec 26, 2022
An Android TextView that always displays an auto refreshing relative time span with respect to a reference time

android-ago This library provides RelativeTimeTextView, a custom TextView that takes a reference time and always displays the relative time with respe

Kiran Rao 658 Dec 21, 2022
a super textview for android

SuperTextView 重磅推出SuperTextView2.x版本,属性参数相比1.x有些变化,1.x的用户升级2.x的时候请注意 1、功能描述 SuperTextView是一个功能强大的View,可以满足日常大部分布局样式,开发者可已自行组合属性配置出属于自己风格的样式!可能描述起来没有概念

Allen 3.7k Dec 29, 2022
Build valid HTML for Android TextView

HTML Builder Build valid HTML for Android TextView. Description There is a lovely method on the android.text.Html class, fromHtml(), that converts HTM

Jared Rummler 527 Dec 25, 2022
ExpandableTextView - Read More TextView for Android

ExpandableTextView Read More TextView for Android Usage Gradle dependencies { implementation 'com.wayne.expandabletextview:expandable-textview:1.1

You kwangwoo 31 Oct 12, 2022
Animation effects to text, not really textview

HTextView Animation effects with custom font support to TextView see iOS Effects see Flutter Effects Screenshot type gif Scale Evaporate Fall Line Typ

hanks 5.5k Jan 5, 2023
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 1, 2023
A Custom TextView with trim text

ReadMoreTextView A Custom TextView with trim text Download To add the ReadMoreTextView library to your Android Studio project, simply add the followin

Borja B. 1.7k Dec 29, 2022