使用遥控器控制安卓电视应用程序 [英] using remote control for android TV application

查看:32
本文介绍了使用遥控器控制安卓电视应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为电视开发 Android 应用程序当我尝试在真正的 Android TV 中测试它时我无法使用遥控器按钮导航到任何按钮或任何东西上、下、左、右.

I'm developing an Android application for TV when I'm trying to test it in the real Android TV I can't navigate to any button or anything using the remote control buttons up, down, left, right.

我已经搜索过了,我发现我必须使用(启用方向键导航)但我不知道如何使用它,我没有找到任何代码或教程我的申请就这么简单.它使动态布局并排,每个布局只有一个按钮和一个回收视图.

I have searched about it and I found that I have to use (Enable D-pad Navigation ) but I don't know how to use this , I didn't find any code or tutorial for it My application is so simple. It makes dynamic layout beside each other and each layout has only one button and one recycle view.

推荐答案

默认情况下,Android 实现了从布局分布推断出的基本 D-Pad 导航.如果您主要使用列表或线性布局,则效果很好.

By default Android implements basic D-Pad navigation inferred from the layout distribution. It works quite well if you use mostly lists or linear layouts.

主要区别在于视图处于聚焦状态而不是选定状态,因此如果您使用自定义背景,即按钮,它可能看起来不起作用,但实际上却是.

The key difference is that the views are on the focused state instead of selected, so if you are using custom background i.e. for buttons it may look like it is not working while in fact it is.

您可以使用键盘上的光标键在模拟器上试用.

You can try it out on an emulator using the cursor keys on the keyboard.

或者,如果推断的导航不起作用,您可以定义每个视图的 nextFocusUp、Down、Left 和 Right.

Alternatively or if the inferred navigation does not work you can define the nextFocusUp, Down, Left and Right per view.

官方文档中对此都有很好的解释:https://developer.android.com/training/tv/start/navigation.html

It is all quite well explained on the official documentation: https://developer.android.com/training/tv/start/navigation.html

这篇关于使用遥控器控制安卓电视应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆