ToggleDrawable

使用贝塞尔曲线轻松绘制动画。「Easy drawable animation using beziers curves. 」

Github星跟踪图

ToggleDrawable

ToggleDrawable helps to create animated drawable transitions using a minimalistic and clean API. The implementation relies on bezier curves instead of SVG graphics, and is compatible below API 19.

DEMO APK

How?

The library provides a few implementations like SearchArrowDrawable, SearchCrossDrawable or DrawerArrowDrawable:

ToggleDrawable drawable = new SearchArrowDrawable(context);
mImageView.setImageDrawable(drawable);
drawable.setProgress(...); // animate

You can easily create your own transitions by passing several Bezier curves to ToggleDrawable:

ToggleDrawable drawable = new ToggleDrawable(context);
drawable.add(<start>, <end>);
drawable.add(<start>, <end>);

Or by simpy subclassing ToggleDrawable instead:

public class MyCustomToggleDrawable extends ToggleDrawable {

        public MyCustomToggleDrawable(Context context) {
            super(context, 0, R.style.CustomToggleDrawableStyle);
            float radius = Math.round(getIntrinsicWidth()*0.5f);
            
            // From circle to square
            add(Bezier.quadrant(radius, 0), Bezier.line(radius, radius, radius, -radius));
            add(Bezier.quadrant(radius, 90), Bezier.line(-radius, radius, radius, radius));
            add(Bezier.quadrant(radius, 180), Bezier.line(-radius, radius, -radius, -radius));
            add(Bezier.quadrant(radius, 270), Bezier.line(-radius, -radius, radius, -radius));
        }
    }

Look at the sample.

Install

This repositery can be found on JitPack:

https://jitpack.io/#renaudcerrato/ToggleDrawable

Add it in your root build.gradle at the end of repositories:

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

Add the dependency:

dependencies {
	        compile 'com.github.renaudcerrato:ToggleDrawable:1.0.2'
	}

主要指标

概览
名称与所有者renaudcerrato/ToggleDrawable
主编程语言Java
编程语言Java (语言数: 1)
平台
许可证Apache License 2.0
所有者活动
创建于2015-12-23 19:11:45
推送于2016-01-25 19:56:13
最后一次提交2016-01-25 13:56:13
发布数3
最新版本名称1.0.2 (发布于 )
第一版名称1.0.0 (发布于 2015-12-24 07:17:23)
用户参与
星数1.1k
关注者数26
派生数125
提交数38
已启用问题?
问题数5
打开的问题数1
拉请求数3
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?