Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我有一个带有搜索栏和播放/暂停/倒带等按钮的播放器视图,这些按钮是具有按下状态和正常状态但没有选定状态的 ImageButtons。
鉴于有许多 android 设备有一个轨迹球作为备用输入(除了触摸屏),我有什么办法可以防止轨迹球聚焦我的一些 UI 元素?问题是,我希望轨迹球仅用于搜索栏,但我不希望用户能够向下/向上滚动以专注于其他按钮。
我尝试在我不想获得焦点的元素上设置 focusable=false,但它不起作用。
这甚至可能吗?
尝试使用
seekbar.requestFocus(); seekbar.setNextFocusUpId(seekbarid); seekbar.setNextFocusDownId(seekbarid); seekbar.setNextFocusLeftId(seekbarid); seekbar.setNextFocusRightId(seekbarid);
这样,即使轨迹球移动,搜索栏也应始终重新获得焦点。