【发布时间】:2021-06-04 04:41:52
【问题描述】:
我正在开发一个在 Android TV 上使用的颤振应用。应用程序具有类似 Netflix 的 UI(如多个水平 ListView 和 Main Vertical ListView) 已添加以下代码以使其与电视遥控器一起使用
Shortcuts(
shortcuts: <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.select): ActivateIntent(),
},
我能够在每个 ListView 内垂直和水平滚动。问题是我无法关注特定的列表视图项目。目标是如果用户使用电视遥控器点击可聚焦项目,它应该打开新页面。
对每个订单项的 UI 使用以下代码。
Focus(
autofocus: true,
child: GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => VideoScreen(id: video.id),
),
),
child:
Container(
margin: EdgeInsets.symmetric(horizontal: 20.0, vertical: 5.0),
padding: EdgeInsets.all(10.0),
height: 140.0,
width: 200,
decoration: BoxDecoration(
color: Colors.black45,
boxShadow: [
BoxShadow(
color: Colors.black12,
offset: Offset(0, 1),
blurRadius: 6.0,
),
],
),
child: Column(
children: [
Row(
children: <Widget>[
Image(
width: 150.0,
image: NetworkImage(video.thumbnailUrl),
)
],
),
Text(
video.title,
style: TextStyle(
color: Colors.white,
fontSize: 18.0,
),
),
RaisedButton(onPressed: (){
})
],
),
),
),
)
我也提到了下面的链接,但不知何故它不起作用: flutter android tv listview focused item change background and text
【问题讨论】:
标签: android flutter dart android-tv