直接的交互界面是用户使用电视用户体验的一个重要方面。当你针对电视优化你的Android应用的时候,你应该特别注意,当使用远程控制替代触摸时用户在你的应用程序中的实际导航。
这节课程向你展示了通过如下如何针对优化导航:
-
确保所有布局控制对支持D-Pad。
-
对UI导航提供高度明显的反馈。
-
将布局控制放置便于访问。
—————————————————————————————————————————————————————————
在电视中,用户使用D-pad或者方向键运行导航控制。这限制了上,下,左,和右的运动。为了构建完美的电视优化应用,你必须一个导航方案,使用它用户能快速学习如何在远程导航你的应用。
Android通常在布局元素之间自动处理导航顺序,所以你不需要额外做任何事情。如果屏幕布局使导航变得困难,或者如果你想用户以一种指定的方式在布局上移动,你可以为你的控制设置明确的导航。例如,为一个android.widget.EditText,定义获取焦点的下一个控件,使用:
<EditText android:id="@+id/LastNameField" android:nextFocusDown="@+id/FirstNameField"\>
为了使用这些明确的导航属性,设置在布局中其它控件ID值(android:id值)。你应该设置循环的导航顺序,以至于最后的控件指引焦点返回到第一个。
注意:你应该仅当系统应用的默认顺序不能很好的工作的时候,使用这些属性来修改导航顺序。
—————————————————————————————————————————————————————————
为在界面中所有的导航和可选择的元素使用合适的高亮颜色。这使得当使用D-pad导航的时候,用户知道这个控件当前是否获取焦点或者可选变得容易。并且,在你的应用中使用高度统一的计划。
Android提供Drawable State List Resourdes类实现被选中或者获取焦点控件的高亮效果。例如:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/button_focused" /> <!-- focused -->
<item android:state_hovered="true"
android:drawable="@drawable/button_focused" /> <!-- hovered -->
<item android:drawable="@drawable/button_normal" /> <!-- default -->
</selector>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/button" />
在可获取焦点和可被选择的控件之间提供足够的填充,以至于在它们周围的高亮是清晰可见的。
—————————————————————————————————————————————————————————
用户应该能通过几次D-pad的点击导航到任何UI控件。导航应该容易并直观的理解。对于一些不直观的动作,使用通过帮助按钮或者帮助栏触发的对话框,给用户提供书面的帮助。
预测用户想导航到的下一个屏幕,并提供一次点击导航到它。如果当前屏幕的UI非常稀疏,考虑使它成为一个多面板屏幕,使用Fragment来实现多面板屏幕。例如,看下面的多面板UI,大陆名称在左侧,并且在每个大陆很酷的地方列表在右侧。
上面的UIyou由三个Fragment组成,left_size_action_controls,continents和placs,正如下面它的xml布局文件所展示。这样的多面板UI使D-pad导航更容易,并是充分利用了电视屏幕的横向控件。
res/layout/cool_places.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<fragment
android:id="@+id/left_side_action_controls"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_marginLeft="10dip"
android:layout_weight="0.2"/>
<fragment
android:id="@+id/continents"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_marginLeft="10dip"
android:layout_weight="0.2"/>
<fragment
android:id="@+id/places"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_marginLeft="10dip"
android:layout_weight="0.6"/>
</LinearLayout>
另外,注意上面的UI布局,动作控件是在左侧的一个竖直滑动列表,使得它们使用D-pad更容易访问。通常,对于使用横向滑动组件的布局,放置动作控件在左侧或者右侧,反之竖向滑动的组件。
分享到:
相关推荐
Android Cookbook: Problems and Solutions for Android Developers by Ian F. Darwin English | 10 May 2017 | ASIN: B071VLZ9ZK | 838 Pages | AZW3 | 12 MB Jump in and build working Android apps with the ...
Manning RxJava for Android Developers Manning RxJava for Android Developers
Kotlin for android developers 中文学习文档 https://leanpub.com/kotlin-for-android-developers 英文版 - Github: https://github.com/wangjiegulu/kotlin-for-android-developers-zh
Kotlin for android developers中文版翻译 Kotlin for android developers中文版翻译
本书介绍Scala基本语法、构造。以及如何将您已经知道的复制java语法转换为Scala,了解Scala除了javabecome之外还提供了哪些功能编程概念和惯用技巧和建议,这些技巧和建议在将现有java项目转换为Scala时非常有用
kotlin for android developers 中文版, kotlin for android developers 中文版
Linux for Developers: Jumpstart Your Linux Programming Skills (Developer's Library) by William "Bo" Rothwell English | 17 Apr. 2017 | ASIN: B06ZY85CPJ | 224 Pages | AZW3 | 5.37 MB Linux for ...
Wiley - Java Programming for Android Developers - For Dummies 2nd - 2017
《Kotlin for android developers中文版翻译》
CalendarProvider是用于用户的日历事务的仓库。CalendarProviderAPI允许你在日历,事务,参与者,提醒等,执行查询,插入,更新,和删除操作。CalendarProvderAPI能通过应用程序和同步Adapter被使用。...
Kotlin-for-Android-Developers:该书的配套应用
kotlin-for-android-developers-zh 中文版本,请支持正版。 https://leanpub.com/kotlin-for-android-developers
Kotlin for android developers(非扫描中文)下载后解压即可,更多请关注我的博客:xiayye5
Kotlin for Android Developers 中文版 ---------------------------------------------------- 本 ePub 基于开源文档,目录书签齐全。 版权归原作者,翻译版权归译者。 ------------------------------------------...
Kotlin for Android Developers - Learn Kotlin the easy way.pdf
kotlin-for-android-developers; kotlin-for-android-developers; kotlin-for-android-developers;
Java Programming for Android Developers For Dummies(2nd) 英文mobi 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Master the fundamentals of Scala and understand its emphasis on functional programming that sets it apart from ...Java developers looking to transition to Scala. No prior experience necessary in Scala.