简体   繁体   中英

How to slow down the speed of shimmer effect

I have tried the demo of shimmer FrameLayout but it goes very fast and I want to slow down the speed of this effect. How to slow down the speed of shimmer effect and how to use the properties of this library?

You need to use app:shimmer_duration="1500" to set speed of animation in ShimmerFrameLayout

Try this

<com.facebook.shimmer.ShimmerFrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:shimmer_duration="1500">

    <View
        android:layout_width="100dp"
        android:layout_height="8dp"
        android:background="#dddddd" />

</com.facebook.shimmer.ShimmerFrameLayout>

Add app:duration="1500" to shimmer FrameLayout by default its duration is 1000 so to slow down i increase the duration

 <com.facebook.shimmer.ShimmerFrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorAccent"
    app:duration="1500"
    android:id="@+id/shimmer">

  <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="#fff"
      android:layout_gravity="center"
      android:textSize="30dp"
      android:text="Shimmer Effect"/>

</com.facebook.shimmer.ShimmerFrameLayout>

Try defining app:shimmer_duration in XML.

eg app:shimmer_duration="1000"

XML Attr: app:shimmer_duration="" You can do the below programmatically -

  val builder = Shimmer.AlphaHighlightBuilder()
  builder.setDuration(500L)
  shimmerFrame.setShimmer(builder.build())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM