- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经在 Kotlin 中创建了扩展 PopupView 的类,并尝试使用 CircleReveal 库为其显示动画。这是我类(class)的功能
fun show(root: View) {
showAtLocation(root, Gravity.CENTER, 0, 0)
val cx = (mainView.left + mainView.right) / 2
val cy = (mainView.top + mainView.bottom) / 2
val dx = Math.max(cx, mainView.width - cx)
val dy = Math.max(cy, mainView.height - cy)
val finalRadius = Math.hypot(dx.toDouble(), dy.toDouble()).toFloat()
with (ViewAnimationUtils.createCircularReveal(mainView, cx, cy, 0f, finalRadius)) {
interpolator = AccelerateDecelerateInterpolator()
duration = 1500
start()
}
}
该代码给我以下错误
java.lang.IllegalStateException: Cannot start this animator on a detached view!
at android.view.RenderNode.addAnimator(RenderNode.java:817)
at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:300)
at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:282)
at android.animation.RevealAnimator.<init>(RevealAnimator.java:37)
at android.view.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:53)
at io.codetail.animation.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:74)
at io.codetail.animation.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:39)
类初始化
class MemberMenu(ctx: Context, val member: Member): PopupWindow(ctx), View.OnClickListener {
val mainView: View
init {
contentView = LayoutInflater.from(ctx).inflate(R.layout.member_menu_layout, null)
mainView = contentView.findViewById(R.id.member_menu_view)
val size = Helpers.dipToPixels(ctx, 240f)
width = size; height = size
setBackgroundDrawable(ColorDrawable())
isOutsideTouchable = true
isTouchable = true
}
.......
最佳答案
不确定,如果它是正确的解决方案,但我只是将该代码移至 OnAttachStateChangeListener
fun show(root: View) {
showAtLocation(root, Gravity.CENTER, 0, 0)
backgroundView.addOnAttachStateChangeListener(this)
}
override fun onViewAttachedToWindow(v: View?) {
if (v==null) return
with(ViewAnimationUtils.createCircularReveal(v, 500, 500, 0f, 500f)) {
interpolator = AccelerateDecelerateInterpolator()
duration = 2500
start()
}
} override fun onViewDetachedFromWindow(v: View?) {}
关于android - 无法在分离 View 上启动动画师,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39817101/
我正在开发一个统一游戏,基本上,我有一个预制件,里面有一个 Sprite 。我创建了一个附加到该 Sprite 的动画。 FrogPrefab |__ FrogSprite 我创建了一个带有公
我制作了一款游戏,当你死后,分数会使用动画从右上角移动到屏幕中间。当您按下“重试”时,我通过设置用作 AnimationState 中的速度倍增器的速度参数来反转动画。 当参数切换值(从 1.0 到
我对 Unity 和一般编码还是陌生的,所以请记住这一点!我也在 Unity 论坛上问过这个问题,但人们告诉我代码应该可以正常编译,而且他们不知所措,所以我希望能在这里找到一些答案! 我试图让我的步行
是否可以将 alpha 动画器应用于 元素而不是整体 AnimatedVectorDrawable 中的元素?如果没有,是否有其他替代方案? 最佳答案 不,元素没有 alpha 属性。 根据 Vec
我是 Cocoa 新手。 我正在努力扩展项目的功能。 该项目的原始功能是打开一个文件并在nsbox(在nswindow中?)中显示文件图标 当我单击菜单打开时,它工作正常。 但是当我以编程方式打开文件
我是一名优秀的程序员,十分优秀!