0
私はリスナーを持っていて、アニメーションでフォーカスのあるアイテムを少し大きくしています。焦点を当てた項目がクリックされたときに、それが実際に正常に戻っカスタムアニメーショントリガーを2回
fun customFunction(): Unit = with(itemView) {
val anim : Animation = AnimationUtils.loadAnimation(itemView.context, R.anim.scale_out)
itemView.startAnimation(anim)
anim.fillAfter = true
}
問題の大きさを変更することは、このリスナー私も作られたカスタム機能のほかに
private fun focus() {
itemView?.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus) {
val anim : Animation = AnimationUtils.loadAnimation(itemView.context, R.anim.scale_in)
itemView.startAnimation(anim)
anim.fillAfter = true
} else {
val anim : Animation = AnimationUtils.loadAnimation(itemView.context, R.anim.scale_out)
itemView.startAnimation(anim)
anim.fillAfter = true
}
}
}
、:focus()
とcustomFunction()
機能は大丈夫働きます。問題は、フォーカスされた要素(customFunction()トリガ)でEnterキーを押すと要素がノーマルにサイズ変更されることです。これは問題ありません。しかし、私が他の要素に移動する瞬間、前のものは2倍のスケールになります。いくつかの項目をクリックしてcustomFunction()をトリガーした場合、私はonFocusListenerを変更して2回スケールアウトしないでください。どんなアイデアも歓迎されます。
で
itemView. setOnFocusChangeListener(null);
– JoshuaMad