react-native - React Native Android TV - 使用遥控器导航时屏幕上的两个元素同时聚焦
问题描述
我正在为 Android TV 开发一个 React Native 应用程序。
我在屏幕顶部有一个按钮,然后在它下面有一个包含网格的容器。当我专注于网格容器中的顶部项目时,我希望能够向上导航到按钮,然后当我专注于按钮时,我希望能够向下导航回顶部的项目网格容器。
我遇到的问题是,Android TV 以与处理按钮相同的方式处理网格中的第一行。
因此,当按钮获得焦点时,网格中的顶部项目将获得焦点,反之亦然 - 两个元素同时获得焦点。向下导航后,网格中的第二行变得聚焦,这很好,但是当再次使用遥控器向上导航时,第一行和按钮都变得聚焦。
这是我的代码:
<View style={{ flex: 1, backgroundColor: theme?.color?.background }}>
<View
style={{
zIndex: 10,
position: 'absolute',
top: 0,
left: 0,
height: theme.height,
paddingLeft: 30,
}}
>
<Button
containerStyles={{
backgroundColor: theme?.color?.background,
marginTop: 6,
}}
title={name}
/>
</View>
<GridContainer
data={data}
onPressCell={onPressCell}
hideTopBar
autoRevealOutOfBounds={autoRevealOutOfBounds}
selectedDate={selectedDate.date}
is12HourClock={is12HourClock}
activityIndicator={loadingIndicator()}
onCellFocus={onCellFocus}
ref={(ref) => {
gridRef.current = ref;
}}
/>
</View>
如何更改布局或代码,以便我可以从Button
元素无缝导航GridContainer
并一次独立地专注于它们?TIA。
解决方案
推荐阅读
- javascript - SVG 未出现在导航栏样式的组件上
- macos - macOS:以 AVFoundation CaptureDevice 访问虚拟相机 (OBS)
- nginx - 如何在 Kubernetes 的 admin.conf 文件中更改服务器?
- python - 访问变量的显式定义
- ssis - 如何设置 SSIS 父包,使 4 个子包可以同时运行,传入不同的参数值?
- angular - Angular + Spring:docker-compose 与 Nginx 配置通信失败
- vba - 在 VBA 中缩放单元格
- javascript - TypeScript - 类型上不存在属性(但存在)?
- asp.net-core - 自定义声明未刷新
- macvim - Mac+Vim:有时用 ASCII 160 插入空格