Android TV 选中高亮显示

1、开发Android TV APP, 使用遥控器选中按钮或者选着其它菜单

如果没有高亮显示,就看不出选中哪个按钮或者菜单

2、在drawable 添加 border_red.xml 设置选中高亮

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="2dp"/>
    <stroke
        android:color="#FF0000"
        android:width="3dp" />
    <solid android:color="#00FF0000" />
</shape>

3、在 layout 添加页面xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <RelativeLayout
        android:focusable="false"
        android:gravity="center"
        android:layout_gravity="center"
        android:clipToPadding="false"
        android:clipChildren="false"
        android:id="@+id/main"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button
            android:id="@+id/button_id_1"
            android:layout_width="match_parent"
            android:gravity="center"
            android:layout_height="wrap_content"
            android:background="#303F9F"
            android:focusableInTouchMode="true"
            android:textColor="#FFF"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="0dp"
            android:text="按钮"
            android:textSize="60dp"
            />

        <Button
            android:id="@+id/button_id_2"
            android:layout_below="@id/button_id_1"
            android:layout_width="match_parent"
            android:gravity="center"
            android:layout_height="wrap_content"
            android:background="#303F9F"
            android:focusableInTouchMode="true"
            android:textColor="#FFF"
            android:text="按钮"
            android:layout_marginTop="30dp"
            android:textSize="60dp"
            />

        <Button
            android:id="@+id/button_id_3"
            android:layout_width="match_parent"
            android:gravity="center"
            android:layout_height="wrap_content"
            android:background="#303F9F"
            android:layout_below="@id/button_id_2"
            android:focusableInTouchMode="true"
            android:textColor="#FFF"
            android:text="按钮"
            android:layout_marginTop="30dp"
            android:textSize="60dp"
            />

    </RelativeLayout>
</LinearLayout>

4、添加选中高亮显示,设置焦点控制

  BorderView border = new BorderView(this);
        border.setBackgroundResource(R.drawable.border_red);

        main = (RelativeLayout) findViewById(R.id.main);
        border.attachTo(main);

时间: 2024-08-04 17:28:31

Android TV 选中高亮显示的相关文章

android TV选中时高亮凸显效果

链接: http://pan.baidu.com/s/1pLjAFQ7 密码: xb8g <ignore_js_op> 360手机助手截图0410_18_02_01.png (335.64 KB, 下载次数: 1) 下载附件 2014-4-10 18:03 上传  <ignore_js_op> 360手机助手截图0410_18_02_02.png (340.2 KB, 下载次数: 0) 选中放大 <ignore_js_op> 360手机助手截图0410_18_02_03

android tv焦点特效实现浅析

Android TV上的焦点凸显特效相信大家都看到过,那么我们就来实现它吧,首先上张效果图. 先说一下实现原理,主要通过重写RelativeLayout实现item,之后在其中加入scalanimation动画效果.刚开始处理时,还是发现了一些问题,比如item放大后会被其他item遮挡,如何添加选中边框等等,以及动画的实现等等.下面放上实现细节. 首先是item的代码: <view xmlns:android="http://schemas.android.com/apk/res/and

TCL Android TV 开发环境搭建实录

要求:Eclipse版本3.5以上 ADT版本10.0.1 TCL的SDK(我看了看核心是Android2.2的API) 步骤: 1.下載SDK和TCL的模拟器 2.Eclipse安装ADT(版本一定要符合哦,要不不行) 3.Eclipse挂载SDK Eclipse环境中设置Window->Preferences,在弹出的对话框中选中第二项Android,在SDK Location中设置解压好的开发包文 件夹路径 4.用下载的TCL的模拟器(emulator.exe)把SDK路径/tools文件

Android TV 盒子开发焦点控制

Android TV app开发与一般Android开发最大的区别在于焦点控制 , 用户在使用Android TV设备主要是通过遥控器操作app. CSDN博客平台看到大牛总结出的2套实用的焦点控制,在此收藏分享: 第一种方法: 采用Android自带的直接控制焦点上下左右的方法.这种方法的前提是必须知道每个view的id,因此在进行布局时有必须要通过view.setId(-)指定view的特定ID,然后通过view.setNextLeftView(-)等四个方法控制该view的上下左右移动后所

第一个Android TV Launcher开源项目

Android TV Launcher开源项目 这个项目是机顶盒桌面,用来播放视频.显示图片.应用管理和其他针对机顶盒产品的设置.目前git和CSDN code上面都没有类似的开源项目,正好本人最近在开发类似产品,网上类似研究还非常少,完全自己实现还是比较困难.所以就把目前的项目开源出来,也有利于其他人少走弯路. git项目地址 CSDN code项目地址 项目框架结构 UI.adapter.实体类.图片cache.网络层. 这个层级关系还是和大部分项目是类似的. 功能模块的详细实现方式 这个部

Android Tv app 与 mobile app 界面呈现的区别

公司的一个项目是android tv的谢了片日报总结:android tv app呈现ui 与手机app的区别 android tv  app和 mobile app 的主要区别在表现形式上 1.焦点移动的处理 从代码上可以明显看出到处都有对焦点获取的处理,这是mobile app所不需要的. 触摸屏与遥控的不同操作方式决定了:tv遥控操作方式在屏幕上是先获取焦点(遥控决定焦点移动)再获取点击,而mobile触摸方式是直接的点击获取与焦点获取一起通常只需要处理点击获取 2.布局边界处理 遥控操作

Android TV APPs 的介绍与创建

最近开始接触到Andorid TV编程,发现目前这方便的资料与比较还比较少,但现在随着产品与用户的升级,涉及到Android TV与 Android Watch的编程离我们越来越近了,本篇博客开始,将以笔记的方式记录我Android TV从零到有的一个过程. 本博客创建步骤主要参考Android官方文档. Get Started with TV Apps TV应用程序使用相同的结构与手机和平板电脑.这种相似性意味着你也可以修改现有的应用程序运行在TV设备或创建新的应用程序基于你现在已经掌握的An

Android TV开发--实现延时关机功能(二)逻辑实现

模块功能描述(总述) 上一篇文章:Android TV开发--实现延时关机功能(一)功能描述 讲的是延时关机整体功能描述以及UI效果,这篇文章将着重讲解逻辑实现. 按照功能模块分为3部分:关机App.关机Service.Launcher 模块图如下: 关机App模块 主要功能:1.展示UI设置延时时长 2.取消延时关机 3.取消延时对话框倒计时功能 1.展示UI设置延时时长 此处即为延时关机功能入口: 1.布局及逻辑处理Activity如下,代码中含有注释: /** * 延时关机 */ publ

Android TV 开发相关文章

Android TV 开发相关文章 Android TV 开发与Android移动设备开发类似,网络上针对其开发文章较少,平时查阅关于TV 开发资料收集于此,方便日后查阅. 持续更新 --. Android TV 焦点特效实现浅析