一款可以四处游动、边缘碰撞检测、跟随手指拖动且能够停靠在侧边栏的有趣小组件
XML 中添加如下代码
<com.storn.viewlib.BubbleTickView
android:id="@+id/ivTick"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="bottom|end" />
组件的宽高可随意设置。
binding.ivTick.post {
binding.ivTick.Builder()
.setX(binding.ivTick.x)
.setY(binding.ivTick.y)
.setWidth(SizeUtils.dp2px(100f))
.setHeight(SizeUtils.dp2px(100f))
.setMaxWidth(binding.rootLayout.width)
.setMaxHeight(binding.rootLayout.height)
.setDozeDuration(3)
.setShowDockDrawable(true)
.setDockDrawable(dock)
.setOriginDrawable(origin)
.move()
}
- hideToSide: 用于隐藏到侧边栏
- dockToSide: 用于停靠在侧边栏
- resetSwimming: 用于设置图片重新游动
binding.ivTick.setOnClickListener {
Toast.makeText(this, "我被电击了,you can do something in here", Toast.LENGTH_SHORT).show()
}