智能電視(電視盒子)開發基礎教程(附sdk),基礎教程sdk
為瞭解決 各種盒子相容問題,各種螢幕的解析度問題,樓主推薦一個 電視開發的sdk ,非常好用
下載
命令列: git clone https://github.com/boxmate/tvframe.git
或者
開啟https://github.com/boxmate/tvframe,右下角 Download Zip
下載檔案中有兩個目錄 frametv/ 為架構工程源碼 framedemo/ 為DEMO樣本工程. 匯入: 一、下載完成後,同平常方式匯入兩個項目,即:File -> Import -> Android -> Existing Projects Into Workspace; 得到兩個工程 RecoTvFrame 架構 RecoTvFrameDemo demo 二、將RecoTvFrame添加為Library 1.選中RecoTvFrame架構工程 右鍵,點擊最下方的Properties 2.點擊左側的Android選項,勾選右下方的 Is Library 3.點確認 三、引入RecoTvFrame 我們以demo工程為例 1.在demo工程上右鍵,點擊最下方的Properties 2.點擊左側的Android選項,點擊右方的 Add 3.選中RecoTvFrame 添加,完成匯入操作 四、處理android-support-v4.jar衝突 1.請先移除你自己的項目中的V4包(libs/ 目錄中),然後複製架構 libs/ 目錄中V4包到你自己的工程對應目錄中, 2.選中V4包右鍵Build Path -> Add To Build Path 五、運行Demo工程(或者你自己的工程)
樓主用這個sdk 開發了一個 helloword
非常簡單
代碼如下
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools/" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px100" android:layout_marginTop="@dimen/px200" android:background="#ff0000" android:text="H" /> <reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px210" android:layout_marginTop="@dimen/px200" android:background="#ff0000" android:text="E" /> <reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px320" android:layout_marginTop="@dimen/px200" android:background="#ff0000" android:text="L" /> <reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px430" android:layout_marginTop="@dimen/px200" android:background="#ff0000" android:text="L" /><reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px540" android:layout_marginTop="@dimen/px200" android:background="#ff0000" android:text="O" /><reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px100" android:layout_marginTop="@dimen/px400" android:background="#00ff00" android:text="W" /> <reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px210" android:layout_marginTop="@dimen/px400" android:background="#00ff00" android:text="O" /> <reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px320" android:layout_marginTop="@dimen/px400" android:background="#00ff00" android:text="R" /> <reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px430" android:layout_marginTop="@dimen/px400" android:background="#00ff00" android:text="L" /><reco.frame.tv.view.TvButton android:layout_width="@dimen/px100" android:layout_height="@dimen/px100" android:layout_marginLeft="@dimen/px540" android:layout_marginTop="@dimen/px400" android:background="#00ff00" android:text="D" /> </RelativeLayout>
就是簡單的一個activity ,然後用sdk中的 tvbutton控制項
然後是個焦點放大效果,
sdk的demo中有很多的 案例,大家可以下來一個一個研究一下,基本上開發一個電視應用就沒什麼大問題了
架構官方首頁:點擊開啟連結