Skip to content

Fix TV D-pad navigation in multi-select action mode toolbar#1550

Open
ihx-rainbow wants to merge 1 commit intozhanghai:masterfrom
ihx-rainbow:master
Open

Fix TV D-pad navigation in multi-select action mode toolbar#1550
ihx-rainbow wants to merge 1 commit intozhanghai:masterfrom
ihx-rainbow:master

Conversation

@ihx-rainbow
Copy link
Copy Markdown

@ihx-rainbow ihx-rainbow commented May 8, 2026

修复 TV 遥控器在多选模式工具栏中的方向键导航问题

Problem / 问题描述

On TV devices, when using the D-pad to navigate the multi-select action
mode toolbar, pressing Right from action_cut does not move focus to
action_copy. Navigation between toolbar action buttons is broken.

在 TV 设备上使用遥控器操作多选模式工具栏时,从 action_cut 按右键后
焦点不会移动到 action_copy,工具栏按钮之间的方向键导航失效。

Root Cause / 根本原因

overlayToolbar and the regular toolbar are stacked in the same
FrameLayout. When the overlay action mode is active, the regular
toolbar is only hidden visually (isVisible = false) but its child
views remain focusable. FocusFinder searches all focusable views by
geometry and finds the regular toolbar's menu buttons (search, sort,
etc.), which overlap with the overlay toolbar's buttons and interrupt
the focus chain.

overlayToolbar 与常规 toolbar 叠放在同一 FrameLayout 中。覆盖层
激活时,常规 toolbar 仅在视觉上隐藏,但其子 View 仍处于可聚焦状态。
FocusFinder 按几何位置搜索所有可聚焦 View,常规 toolbar 的菜单按钮
(搜索、排序等)与覆盖层菜单项位置重叠,打断了焦点链路。

Fix / 修复方案

Pass the regular toolbar as a siblingView to OverlayToolbarActionMode.
When the overlay is shown, set siblingView.descendantFocusability to
FOCUS_BLOCK_DESCENDANTS to exclude all its children from focus search.
Restore it to FOCUS_BEFORE_DESCENDANTS when the overlay is hidden.

将常规 toolbar 作为 siblingView 传入 OverlayToolbarActionMode
覆盖层显示时,将 siblingView.descendantFocusability 设置为
FOCUS_BLOCK_DESCENDANTS,阻止其所有子 View 参与焦点搜索;
覆盖层隐藏时恢复为 FOCUS_BEFORE_DESCENDANTS

这个项目很不错,美观又好用,我装到 tv 设备上之后,只能用遥控器操作,发现往右选不到删除按钮,需要优化下。
我写后端的,前端不是很熟,这个 pr 可以不用 merge,希望作者可以帮忙改下发个版本十分感谢!

…vigation

修复:多选模式覆盖工具栏激活时阻止底层工具栏获取焦点,以修复 TV 遥控器导航问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant