【问题标题】:How to slow down the speed of shimmer effect如何减慢微光效果的速度
【发布时间】:2018-08-30 03:50:11
【问题描述】:

我已经尝试过 shimmer FrameLayout 的演示,但它的速度非常快,我想放慢这个效果的速度。如何减慢shimmer效果的速度以及如何使用这个库的属性?

【问题讨论】:

  • 是的@NileshRathod
  • 我不能,因为你的答案不正确@NileshRathod
  • 你能解释一下为什么
  • 首先属性是 app:duration 而不是 shimmer:duration,第二个最重要的是默认速度是 1000,所以要减慢速度,我们必须增加持续时间 @NileshRathod跨度>
  • 检查我的 ans shimmer:duration="1500" and it is also valid shimmer:duration` 我已经在我的设备上测试过了

标签: android


【解决方案1】:

ShimmerFrameLayout

中需要使用app:shimmer_duration="1500"设置动画速度

试试这个

<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>

【讨论】:

    【解决方案2】:

    app:duration="1500" 添加到微光FrameLayout 默认情况下其持续时间为1000,因此为了减慢我增加持续时间

     <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>
    

    【讨论】:

      【解决方案3】:

      尝试在 XML 中定义 app:shimmer_duration

      例如app:shimmer_duration="1000"

      【讨论】:

      • 错误:(10) 在包 'com.user.shimmereffectdemo' 中找不到属性 'shimmer_duration' 的资源标识符
      【解决方案4】:

      XML 属性:app:shimmer_duration="" 您可以以编程方式执行以下操作 -

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-20
        • 1970-01-01
        • 2022-01-13
        • 1970-01-01
        相关资源
        最近更新 更多