EasyFloat
EasyFloat copied to clipboard
点击悬浮窗View,用ValueAnimator改变View 的高度或者宽度,出现卡顿的情况。
` private fun showActivityFloat(tag: String) { EasyFloat.with(this) .setSidePattern(SidePattern.RESULT_HORIZONTAL) .setImmersionStatusBar(true) .setGravity(Gravity.END, 0, 10) // 传入View,传入布局文件皆可,如:MyCustomView(this)、R.layout.float_custom .setLayout(MyCustomView(this)) { it.findViewById<TextView>(R.id.textView).setOnClickListener { v -> toast() heightAnimator(v) } } .show() }
private fun heightAnimator(v: View){
val valueAnimator = ValueAnimator.ofInt(v.height,v.height + 200)
valueAnimator.addUpdateListener {
val params = v.layoutParams
params.height = it.animatedValue as Int
v.layoutParams = params
}
valueAnimator.start()
}
`
运行项目的Demo,在放大View的时候也有卡顿的情况,真是奇怪了,缩小就没有
怎么解决呢
demo中 可以增加回调间隔时间限制,以下限制 25ms回调一次
MotionEvent.ACTION_MOVE -> { if (System.currentTimeMillis() - lastUpdateTime > 25) { lastUpdateTime = System.currentTimeMillis() onScaledListener?.onScaled(event.x - touchDownX, event.y - touchDownY, event) } }