Git Product home page Git Product logo

shimmer-android's Introduction

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.

shimmer-android's People

Contributors

eveliotc avatar keanupang avatar michaelevans avatar romainpiel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shimmer-android's Issues

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

Text View with a drawable

Was wondering if the there is some way that i can get the shimmer effect with a drwable in the shimmer text view?

Memory Leak

Does the Runnable inside Shimmer.java properly stop? It seems to be causing a memory leak for me.

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

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)

Android 2.x support

I really hate to bring this up myself but it's reality that the large portion of devices out there is running on Android 2.x.
Would you consider replace animation related package imports to NineOldAndroid?

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

How to change font?

its wonder full project that you have done, i'm using this project in my app but is there any option in set different font

Main manifest has <uses-sdk android:minSdkVersion='8'> but library uses minSdkVersion='14'

I want to reference the library in my project(https://github.com/snowdream/android-widgets).i get the error as follows.
It seems that the minSdkVersion of my project is 8, but your minSdkVersion is 14.
If your library is avaiable for minSdkVersion 8, can you modify it to minSdkVersion 8,thank you.

[/home/snowdream/workspace/git/android-widgets/lib/src/main/AndroidManifest.xml, /home/snowdream/workspace/git/android-widgets/lib/build/exploded-aar/com.romainpiel.shimmer/library/1.2.0/AndroidManifest.xml:2]   
Main manifest has <uses-sdk android:minSdkVersion='8'> but library uses minSdkVersion='14'

Can this work with arbitrary views?

Currently the Shimmer is just a TextView on Steroids. Couldn’t it support any view and views hierarchy as the original iOS version does?

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

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)

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.

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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.