登录

去注册 忘记密码?

登录

注册

去登录

  • 扫码关注公众号
  • 发送“我爱安卓
  • 即可获取验证码

注册

解锁回答区域

  • 扫码关注公众号
  • 发送“我爱安卓

若你登陆,将永久解锁;
若未登录,仅本机解锁。

解锁回答区域

获取注册验证码

  • 扫码关注公众号
  • 发送“我爱安卓
  • 即可获取验证码

Android 自定义 View 之 LeavesLoading

LinYaoTian   2019-02-17 21:25   收藏

LeavesLoading

1. 创意原型

Gif 原图:

效果图:

test1 (1).gif

基本实现了原图的效果

2. 如何添加进项目中

  • 方式一:

    下载 LeavesLoading Library 拷贝进工程中。

  • 方式二:

    在 project 的 build.gradle 中:

    allprojects {
    	repositories {
    		...
    		maven { url 'https://jitpack.io' }
    	}
    }
    

    在 app 的 build.gradle 中:

    implementation 'com.github.LinYaoTian:LeavesLoading:1.0.1'
    

3. 如何使用

3.1 简单使用

在布局文件中

 <com.rdc.leavesloading.LeavesLoading
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/myleaf"/>

在 Activity 中

LeavesLoading leavesLoading = findViewById(R.id.myleaf);
leavesLoading.setProgress(50);

3.2 方法

方法名描述
setLeafSrc(int resId)设置叶子图片
setFanSrc(int resId)设置风扇图片
setProgress(int progress)设置进度
setProgressColor(int color)设置进度条颜色
setLeafNum(int num)设置叶片数目
setLeafFloatTime(long time)设置叶子飘动一个周期所花时间
setLeafRotateTime(long time)设置叶子旋转一周所花时间
setFanRotateSpeed(int speed)设置风扇旋转速度
setFanStroke(int color)设置风扇外圈颜色
setBgColor(int color)设置背景颜色

3.3 Attributes属性(在布局文件中调用)

Attributesformadescribe
leafSrcreference叶子图片
leafNuminteger叶子数目
fanSrcreference风扇图片
bgColorcolor背景颜色
progressinteger进度值(0-100)
progressColorcolor进度条颜色
leafFloatSpeedinteger叶子飘动一个周期所花时间
leafRotateSpeedinteger叶子旋转一周所花时间
fanRotateSpeedinteger设置风扇旋转速度
fanStrokeColorcolor风扇外圈颜色

4. About Me

作者掘金博客:Lin_YT

项目地址:https://github.com/LinYaoTian/TestLeavesLoading