为了解决 各种盒子兼容问题,各种屏幕的分辨率问题,楼主推荐一个 电视开发的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添加为Library1.选中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>
然后是个焦点放大效果,
sdk的demo中有很多的 案例,大家可以下来一个一个研究一下,基本上开发一个电视应用就没什么大问题了
框架官方主页:点击打开链接