Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

Android TV 開發總結(二):打造 TV Metro 風格介面

編輯:關於 Android 程式設計

前言:上一篇介紹了建構 TV app 前要知道的一些事情。開發 Android TV 與手機本質上沒有太大差別,螢幕大、焦點處理與按鍵處理是它有別於手機和平板的實質差異。本文將介紹 TV 中的 Metro UI 風格,並結合實例說明。

Android TV 的發展離不開 Metro UI。先看最新的泰捷 TV 會員區效果,屬於典型的 Metro 風格:

什麼是 Metro UI

Metro 的設計意念源自交通局的巴士站牌、機場與地鐵指示牌,給了微軟設計團隊靈感。設計團隊表示 Metro 源自美國華盛頓州金縣都會交通局(King County Metro)的標識設計,其風格大量採用大字體以吸引目光。微軟認為 Metro 設計主題應是「光滑、快、現代」,其圖標設計也與 Android 和 iOS 不同。

Metro UI 軟體

Metro 是微軟為方便開發者編寫 Metro 風格程式而提供的開發平台,可呼叫微軟 WinRT 暴露出來的介面。Metro 風格的控件擴展了 Win8 標準控件的方法與屬性,實現一些新功能。在 Windows 8 中開放的應用程式市場也採用並推薦 Metro 風格介面的應用程式。

Metro 介面是開機後首先映入眼簾的第一個介面,主要為觸屏設備設計,但在 TV 中使用起來也一樣方便。我們安裝的程式以及從應用商店下載的程式都會在 Metro 中呈現,因此需定期對其進行分組、排序與整理,以便操作並維持介面美觀。Metro 介面同時提供了便捷的選項,使操作更加方便。

案例效果

本文仿照並實現這個 Metro 介面,以下為實現的效果圖:

gif 圖(TV 上沒有好的錄屏工具,盒子系統一般低於 5.0,我用的是 i71,很老的盒子,基於 API 17、4.2.2 的系統):


源碼分析

看下其中一個 MetroItem 的布局:



每一個 MetroItemFrameLayout 下包含一些子 View:ImageView 對應圖片,CornerView 表示上下左右的角標,TextView 表示下方的描述,這些可依具體情況選擇。



其他相關程式碼將於下篇博客具體分析。案例已開源到 Github,對應鏈接:https://github.com/hejunlin2013/TVSample,喜歡可以給個 star。

License

 Copyright (C) 2016 hejunlin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved