Android TV 官方教程简读1-Building Apps for TV
2017-09-27 00:10
411 查看
官方文档
TV 应用中有一个比较常见的词
如果不使用 CATEGORY_LEANBACK_LAUNCHER 声明,应用将不会出现的 Google Play,使用开发工具加载 APP 到 TV 也不会出现在界面上
Use the android:banner attribute with the tag to supply a default banner for all application activities, or with the tag to supply a banner for a specific activity.
banner 的要求
Banners are images that represent the face of your app or game on the home screens of Android TV devices and serve as a way for users to launch your app. Here are the requirements for your banner image:
Size: 320 x 180 px, xhdpi resource
文字必须包含在图片中,如果应用是多语言的,还有提供对应的banner。
TV 上开启开发者模式,开启 USB 调试,运行即可。
模拟器直接运行。
TV 应用中有一个比较常见的词
Leanback,找了半天翻译,靠谱点儿的就是“靠着看” - -
Declare a TV Activity
不同于手机 APP 应用,TV 应用的 Launcher 声明使用的是CATEGORY_LEANBACK_LAUNCHER
<application android:banner="@drawable/banner" > ... <activity android:name="com.example.android.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.android.TvActivity" android:label="@string/app_name" android:theme="@style/Theme.Leanback"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> </intent-filter> </activity> </application>
如果不使用 CATEGORY_LEANBACK_LAUNCHER 声明,应用将不会出现的 Google Play,使用开发工具加载 APP 到 TV 也不会出现在界面上
Declare Leanback support
<manifest> <uses-feature android:name="android.software.leanback" android:required="false" /> // true 只运行在 Leanback UI, false 可以运行在手机、手表、TV等设备 ... </manifest>
Declare touchscreen not required
声明不依赖触摸屏,这是必须的,否则不会出现的TV 上的 Google Play 中<manifest> <uses-feature android:name="android.hardware.touchscreen" android:required="false" /> ... </manifest>
Provide a home screen banner
<application ... android:banner="@drawable/banner" > ... </application>
Use the android:banner attribute with the tag to supply a default banner for all application activities, or with the tag to supply a banner for a specific activity.
banner 的要求
Banners are images that represent the face of your app or game on the home screens of Android TV devices and serve as a way for users to launch your app. Here are the requirements for your banner image:
Size: 320 x 180 px, xhdpi resource
文字必须包含在图片中,如果应用是多语言的,还有提供对应的banner。
Change the launcher color
当启动 TV 应用时,系统会使用动画如展开的实心圆,为了自定义动画颜色,可以使用android:colorPrimary属性,同时设置两个额外的 transition overlap 属性为 true
<resources> <style ... > <item name="android:colorPrimary">@color/primary</item> <item name="android:windowAllowReturnTransitionOverlap">true</item> <item name="android:windowAllowEnterTransitionOverlap">true</item> </style> </resources>
Add TV support libraries
TV 支持包不是必须的,但是推荐使用 v17 leanback library,依赖于V7、V4等其它包。开发应用,运行
在 TV 和模拟器上运行 APP 的方法和步骤,和在手机端是一样的。TV 上开启开发者模式,开启 USB 调试,运行即可。
模拟器直接运行。
相关文章推荐
- Android TV 官方教程简读3-Building Layouts for TV
- Android TV-Building TV Apps,Get Started with TV Apps
- Android TV - 1.3 Building Layouts for TV
- Building Apps for Windows Phone 8.1教程下载地址整理
- Android TV -2- Building TV Playback Apps
- Android TV 官方教程简读4-Creating TV Navigation
- android tv-Building TV Games
- PhoneGap: open source development framework for building cross-platform mobile apps, Build apps in HTML and JavaScript
- Android TV -1.1- Get Started with TV Apps
- google官方mvp示例for Android apps
- Android API Guide for Media Apps(四)—— 构建媒体浏览器服务(Building a Media Browser Service)
- TensorFlow官方教程学习笔记之3-用于机器学习专家学习的MNIST数据集(MNIST For ML Beginners)
- Introduction to Model/View/ViewModel pattern for building WPF apps
- Android API Guide for Media Apps(五)——构建媒体浏览客户端(Building a Media Browser Client)
- IBatisNet的ExecuteQueryForMap和QueryForDictionary用法的官方完全详细实例教程
- Android Auto-Building Apps for Auto,Getting Started with Auto
- Android Wear 进阶0.1 进阶表: Developing for Android Wear - Building Apps for Wearables
- TensorFlow官方教程学习 Deep MNIST for Experts
- TensorFlow官方教程学习 MNIST For ML Beginners
- Caffe for Python 官方教程(翻译)