Code Monkey home page Code Monkey logo

shimmer-android's Introduction

Shimmer for Android

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.2.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 romainpiel avatar

Watchers

 avatar  avatar

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.