在通过导航组件添加到动作的动画完成之前

在通过导航组件添加到动作的动画完成之前

本文介绍了在通过导航组件添加到动作的动画完成之前,防止单击视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
钩住code>对象本身.

What I found in the documentation is that I could get resource ID of that animation through NavOptions object hooked onto the NavAction, but not the Animation object itself.

推荐答案

您可以先在XML android:enabled ="false" 中禁用视图,然后在片段的 onViewCreated中禁用视图,您可以使用协程设置动画持续时间的 delay :

You can start by having your views as disabled in xml android:enabled="false" then in your fragment's onViewCreated you can set a delay with the animation duration using coroutines:

override fun onViewCreated(view: View, savedState: Bundle?) {
    super.onViewCreated(view, savedState)

    // Initialize views here.


    lifecycleScope.launch {
        delay(resources.getInteger(R.integer.anim_duration).toLong())
        // Enable views here
        myView.isEnabled = true
    }
}

这篇关于在通过导航组件添加到动作的动画完成之前,防止单击视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 10:04