Convert Figma logo to code with AI

romainpiel logoShimmer-android

(DEPRECATED) An Android TextView with a shimmering effect

1,995
438
1,995
13

Top Related Projects

An easy, flexible way to add a shimmering effect to any view in an Android app.

DEPRECATED - Memory efficient shimmering effect for Android applications by Supercharge.

A library provides an easy way to show skeleton loading view like Facebook and Alipay

Quick Overview

Shimmer-android is an Android library that provides a shimmering effect for views in Android applications. It creates an animated gradient effect that can be applied to various UI elements, often used as a loading placeholder or to draw attention to specific parts of the interface.

Pros

  • Easy to implement and integrate into existing Android projects
  • Customizable appearance with options for color, angle, and animation duration
  • Lightweight library with minimal impact on app performance
  • Compatible with various Android versions and view types

Cons

  • Limited to a specific visual effect, which may not suit all design needs
  • Requires additional setup for complex view hierarchies
  • May not be actively maintained (last update was several years ago)
  • Documentation could be more comprehensive

Code Examples

  1. Basic shimmer effect on a TextView:
val shimmerTextView = ShimmerTextView(this)
shimmerTextView.setText("Shimmering Text")
shimmerTextView.startShimmerAnimation()
  1. Customizing shimmer appearance:
val shimmer = Shimmer()
shimmer.setDirection(Shimmer.ANIMATION_DIRECTION_LTR)
shimmer.setDuration(1500)
shimmer.setStartDelay(300)

val shimmerView = ShimmerFrameLayout(this)
shimmerView.setShimmer(shimmer)
  1. Applying shimmer to a layout:
val shimmerLayout = ShimmerFrameLayout(this)
shimmerLayout.addView(yourExistingLayout)
shimmerLayout.startShimmerAnimation()

Getting Started

  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.romainpiel.shimmer:library:1.4.0@aar'
}
  1. Add the ShimmerFrameLayout to your XML layout:
<com.romainpiel.shimmer.ShimmerFrameLayout
    android:id="@+id/shimmer_view_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <!-- Add your views here -->

</com.romainpiel.shimmer.ShimmerFrameLayout>
  1. Start the shimmer animation in your Activity or Fragment:
val shimmerViewContainer = findViewById<ShimmerFrameLayout>(R.id.shimmer_view_container)
shimmerViewContainer.startShimmerAnimation()

Competitor Comparisons

An easy, flexible way to add a shimmering effect to any view in an Android app.

Pros of shimmer-android

  • More comprehensive and feature-rich implementation
  • Better performance optimization for large views
  • Wider range of customization options

Cons of shimmer-android

  • Larger library size due to additional features
  • Slightly more complex setup and configuration
  • Less frequently updated (last update in 2018)

Code Comparison

Shimmer-android (romainpiel):

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

shimmer-android (facebookarchive):

ShimmerFrameLayout container = (ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);
container.setDuration(1500);
container.startShimmer();

The Facebook version offers more control over the shimmer effect through the ShimmerFrameLayout, allowing for easier integration with existing layouts and more granular customization of the animation properties.

Both libraries provide a simple way to add shimmer effects to Android applications, but the Facebook version offers more features and flexibility at the cost of a slightly more complex implementation. The choice between the two depends on the specific requirements of the project and the desired level of customization.

DEPRECATED - Memory efficient shimmering effect for Android applications by Supercharge.

Pros of ShimmerLayout

  • More recent and actively maintained (last update in 2023 vs 2017 for Shimmer-android)
  • Supports both Java and Kotlin
  • Offers more customization options, including shimmer color, angle, and shape

Cons of ShimmerLayout

  • Slightly larger library size
  • May have a steeper learning curve due to more configuration options
  • Less established in the community compared to Shimmer-android

Code Comparison

Shimmer-android:

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

ShimmerLayout:

shimmerLayout.startShimmer()
shimmerLayout.setShimmerColor(Color.RED)
shimmerLayout.setShimmerAngle(45)

ShimmerLayout offers more granular control over the shimmer effect, allowing developers to customize various aspects of the animation. However, Shimmer-android provides a simpler API for basic use cases.

Both libraries achieve similar results, but ShimmerLayout's active development and additional features make it a more versatile choice for modern Android projects. Developers should consider their specific requirements and the level of customization needed when choosing between these libraries.

Pros of ShimmerRecyclerView

  • Specifically designed for RecyclerView, making it easier to implement shimmer effects in list-based layouts
  • Provides built-in support for different shimmer layouts and customization options
  • More recent and actively maintained repository

Cons of ShimmerRecyclerView

  • Limited to RecyclerView implementations, less flexible for other view types
  • May have a steeper learning curve for developers not familiar with RecyclerView

Code Comparison

Shimmer-android:

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

ShimmerRecyclerView:

shimmerRecyclerView.showShimmerAdapter();
shimmerRecyclerView.hideShimmerAdapter();

Summary

ShimmerRecyclerView is tailored for RecyclerView implementations, offering more specific features and customization options for list-based layouts. It's more recently maintained and provides built-in support for different shimmer layouts. However, it's limited to RecyclerView and may be less flexible for other view types.

Shimmer-android, on the other hand, offers a more general-purpose shimmer effect that can be applied to various view types, making it more versatile. Its implementation is simpler, but it may lack some of the advanced features and customization options provided by ShimmerRecyclerView.

The choice between the two libraries depends on the specific requirements of your project and whether you're primarily working with RecyclerView or need a more general shimmer effect solution.

A library provides an easy way to show skeleton loading view like Facebook and Alipay

Pros of Skeleton

  • More comprehensive and flexible, offering multiple skeleton styles and customization options
  • Supports both RecyclerView and ViewGroup layouts
  • Actively maintained with recent updates and bug fixes

Cons of Skeleton

  • Slightly more complex implementation due to additional features
  • May have a larger library size compared to Shimmer-android
  • Potential performance overhead for complex layouts

Code Comparison

Shimmer-android:

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

Skeleton:

Skeleton.bind(recyclerView)
    .adapter(adapter)
    .load(R.layout.item_skeleton)
    .show();

Key Differences

  • Skeleton provides more built-in options for creating loading effects
  • Shimmer-android focuses specifically on the shimmer animation effect
  • Skeleton offers easier integration with RecyclerView and ViewGroup
  • Shimmer-android has a simpler API for basic shimmer effects

Use Cases

  • Choose Skeleton for more complex loading animations and greater flexibility
  • Opt for Shimmer-android if you only need a simple shimmer effect with minimal setup

Community and Support

  • Skeleton has more recent activity and a larger number of contributors
  • Shimmer-android has been around longer but has less recent development

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

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.