当前位置:网站首页>RecyclerView通过DPAD按键上下切换焦点 切换到界面外的控件时焦点会左右乱跳
RecyclerView通过DPAD按键上下切换焦点 切换到界面外的控件时焦点会左右乱跳
2022-07-29 04:28:00 【呈叙墨客】
焦点乱跳原因
乱跳原因Android原生焦点跳转逻辑设计如此(算是bug吧)。
原生逻辑是根据屏幕显示位置来计算下一个焦点位置,但在切换到屏幕外面时会有问题,比如第2列上移到屏幕为会跳到第3列,第1列下移到屏保外时,会跳到第1列。
解决办法
无效的解决办法:重写 dispatchKeyEvent,如果是在最底部,按键事件派发时,view还没创建。无法解决屏幕外的焦点控制。
有效解决办法:
重写 requestChildFocus 和 dispatchKeyEvent。
package com.android.xxx.view;
import android.content.Context;
import <边栏推荐
- LeetCode_ Stack topics
- LeetCode(剑指 Offer)- 53 - I. 在排序数组中查找数字 I
- Classes and objects (I)
- Definition and implementation of stack and queue (detailed)
- Why is it necessary to scale the attention before softmax (why divide by the square root of d_k)
- Vscode one click compilation and debugging
- 读懂 互联网巨头 【中台之战】 以及 中台 发展思维
- 【Express连接MySQL数据库】
- C language: summary of consortium knowledge points
- 你真的会写Restful API吗?
猜你喜欢

用 ZEGO Avatar 做一个虚拟人|虚拟主播直播解决方案

There are objections and puzzles about joinpoint in afterreturning notice (I hope someone will leave a message)

redux快速上手

11.备份交换机

Don't insist on 66 days. Weight generates random numbers

Sequence list and linked list

不会就坚持60天吧 神奇的字典

Make a virtual human with zego avatar | virtual anchor live broadcast solution

Can you really write restful API?

使用容器部署Jenkins
随机推荐
9.延迟队列
Realize the effect of univariate quadratic equation through JS. Enter the coefficients of a, B and C to calculate the values of X1 and x2
不会就坚持60天吧 神奇的字典
i++与++i详解
[C language] power table of 3 generated by PTA 7-53
Don't stick to it for 68 days. Baboons eat bananas
kotlin的List,Map,Set等集合类不指定类型
Mpc5744p introduction and opensda firmware update
C language: typedef knowledge points summary
Pytoch automatic mixing accuracy (AMP) training
STL source code analysis (Hou Jie) notes -- Classification and testing of stl containers
TypeError: Cannot read properties of undefined (reading ‘then‘)
File operation (Advanced C language)
Machine vision Series 1: Visual Studio 2019 dynamic link library DLL establishment
不会就坚持62天吧 单词之和
Shell string segmentation
Implementation of jump connection of RESNET (pytorch)
Back propagation process of manual BP neural network
Redux quick start
Mongo shell interactive command window