快速实现微光效果
导入 Shimmer 库
dependencies {
...
implementation 'com.github.huangziye:Shimmer:${latest_version}'
...
}
复制代码
Usage
//ViewGroup
var ll = findViewById<LinearLayout>(R.id.ll)
// set shimmer effect
ShimmerUtil.with(ll).renderChilds()
// hide shimmer effect
Handler().postDelayed({ShimmerUtil.with(ll).removeChilds()},5000)
//View
var textView = findViewById<TextView>(R.id.tv)
ShimmerUtil.with(textView).render()
ShimmerUtil.with(textView).remove()
//Optional operation
ShimmerUtil.with(textView)
// set draw rect color
.color(color)
// set draw rect radius
.radius(radius)
//set alpha
.alpha(alpha)
// draw rect
.drawRect(drawRect)
.drawRect(width, height)
//set filter: default filter DefaultOnShimmerFilter
.filter(filter)
复制代码
效果图
快来试试吧,是不是很简单!!!