zoukankan      html  css  js  c++  java
  • 安卓开发打造闪光控件效果

     

    使用方法;
    配置工程
    首先,我们在GitHub上将该项目clone到本地;
    https://github.com/facebook/shimmer-android
    接下来我们在Android studio中导入所需要的module, 即shimmer-android;
    最后,需要配置一下下自己的gradle,引用该module:
    dependencies {
    compile project(‘:shimmer-android’)
    }

    xml布局文件,将需要加入特效的控件用ShimmerFrameLayout包裹

           <!--会员等级-->
                            <com.facebook.shimmer.ShimmerFrameLayout
                                android:id="@+id/shimmerContent"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                               >
                                <Button
                                    android:id="@+id/btn_huiyuanlevel"
                                    android:layout_width="60dp"
                                    android:layout_height="18dp"
                                    android:layout_marginLeft="10dp"
                                    android:layout_marginTop="2dp"
                                    android:layout_toRightOf="@id/huiyan_name"
                                    android:background="@drawable/qingtonghuiyuanbg"
                                    android:gravity="center"
                                    android:text="青铜会员"
                                    android:textColor="#648728"
                                    android:textSize="12sp" />
                            </com.facebook.shimmer.ShimmerFrameLayout>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    java代码中设置启动发光字配置属性

          ShimmerFrameLayout shimmerFrameLayout = (ShimmerFrameLayout) findViewById(R.id.shimmerContent);
            shimmerFrameLayout.setRepeatMode(ObjectAnimator.REVERSE);
            shimmerFrameLayout.setDuration(1000);
            shimmerFrameLayout.setDropoff(0.4f);//设置光的宽度
            shimmerFrameLayout.setBaseAlpha((float) 0.9);//设置没有光照的地方的透明度
    //        shimmerFrameLayout.setIntensity(6);//设置光的强度
            //设置光的形状,线性ShimmerFrameLayout.MaskShape.LINEAR(默认),ShimmerFrameLayout.MaskShape.RADIAL圆形
            shimmerFrameLayout.setMaskShape(ShimmerFrameLayout.MaskShape.RADIAL);
            shimmerFrameLayout.startShimmerAnimation();
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
  • 相关阅读:
    C标准库函数实现
    每天一句话
    移植数码相框到arm开发板上
    数据管理
    perl 分割文件路径和文件名
    恶补英语 拿 The C programming language 练功
    英语学习 chapter1
    uboot 烧写过程
    MVC,去掉字符串中的html代码
    排序之希尔排序
  • 原文地址:https://www.cnblogs.com/totoo/p/shimmerFrameLayout.html
Copyright © 2011-2022 走看看