使用github开源项目(非常感谢作者):
这里是项目地址:https://github.com/evilbinary/TvWidget

1.个人只需要RelativeLayout 布局,所以只是用了里边的TvZorderRelativeLayout

将TvZorderRelativeLayout.class复制到项目中

public class TvZorderRelativeLayout extends RelativeLayout {private int position = 0;public TvZorderRelativeLayout(Context context) {super(context);}public TvZorderRelativeLayout(Context context, AttributeSet attrs) {super(context, attrs);this.setChildrenDrawingOrderEnabled(true);}public void setCurrentPosition(int pos) {this.position = pos;}@Overridepublic boolean dispatchKeyEvent(KeyEvent event) {View focused = findFocus();int pos = indexOfChild(focused);if (pos >= 0 && pos < getChildCount()) {setCurrentPosition(pos);postInvalidate();}return super.dispatchKeyEvent(event);}@Overrideprotected int getChildDrawingOrder(int childCount, int i) {View v = getFocusedChild();int pos = indexOfChild(v);if (pos >= 0 && pos < childCount)setCurrentPosition(pos);if (i == childCount - 1) {//这是最后一个需要刷新的itemreturn position;}if (i == position) {//这是原本要在最后一个刷新的itemreturn childCount - 1;}return i;//正常次序的item}}

这个类主要是修改了ViewGroup 的绘制顺序,解决放大布局不被后边的布局遮挡
参看:https://blog.csdn.net/liweicai137/article/details/50826596

protected int getChildDrawingOrder (int childCount, int i)
返回迭代的绘制子类索引。如果你想改变子类的绘制顺序就要重写该方法。默认返回 i 值。
提示:为了能够调用该方法,你必须首先调用setChildrenDrawingOrderEnabled(boolean)来允许子类排序。

在调用draw()方法时,将会调用getChildDrawingOrder(int childCount ,int i)方法
ViewGroup 中默认是从上绘制到下,如果有需要改变绘制的 先后的顺序,就可以从写改方法(不改变位置

2.还有两个类 BorderView,BorderEffect 复制到项目中,这两个类主要是 边框view移动放大动画还有宽高计算等
3.使用:

1.activity_main.xml ---------TvZorderRelativeLayout作为父布局

<com.jyh.tvtest.TvZorderRelativeLayoutandroid:id="@+id/main"android:layout_width="match_parent"android:layout_height="match_parent"android:clipChildren="false" //用来定义他的子控件是否要在他应有的边界内进行绘制。 默认情况下,clipChild被设置为trueandroid:clipToPadding="false" //用来定义ViewGroup是否允许在padding中绘制。默认情况下,cliptopadding被设置为ture><RelativeLayoutandroid:id="@+id/test1_rl"android:layout_width="260dp"android:layout_height="match_parent"android:background="@color/color1"android:clickable="true"android:focusable="true"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="模块1"android:textSize="36sp"android:textColor="@color/white"/></RelativeLayout><RelativeLayoutandroid:id="@+id/test2_rl1"android:layout_width="200dp"android:layout_height="140dp"android:layout_toRightOf="@+id/mirrcast_rl"android:background="@color/color2"android:layout_margin="2dp"android:clickable="true"android:focusable="true"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="模块2"android:textSize="36sp"android:textColor="@color/white"/></RelativeLayout>...</com.jyd.tvtest.TvZorderRelativeLayout>
  1. MainActivity
 public class MainActivity extends Activity implements View.OnClickListener{RelativeLayout main;RelativeLayout test1_rl;RelativeLayout test2_rl1;...@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);BorderView border = new BorderView(this);border.setBackgroundResource(R.drawable.border_highlight);//9.png高亮框main = (RelativeLayout) findViewById(R.id.main);test1_rl= findViewById(R.id.test1_rl);test2_rl1 = findViewById(R.id.test2_rl1);...test1_rl.setOnClickListener(this);test2_rl1 .setOnClickListener(this);...border.attachTo(main);}

android TV 焦点选中放大效果相关推荐

  1. android xml 焦点,android TV 焦点选中放大效果

    使用github开源项目(非常感谢作者): 这里是项目地址:https://github.com/evilbinary/TvWidget 1.个人只需要RelativeLayout 布局,所以只是用了 ...

  2. Android仿微信头像放大效果

    android仿微信头像放大效果,使用Dialog+Gallery 实现 1.  dialog显示时的动画style,动画可以自己根据喜好自己设置,此处动画xml省略 <style name=& ...

  3. Android TV开发 视频窗口选中放大效果的实现

    先上效果图 视频模块的布局是这样的: <RelativeLayoutandroid:id="@+id/first_view_rl"android:layout_width=& ...

  4. android tv 焦点居中自定义listview控件的实现

    因为项目需要,花了一天做了一个自定义listview,和google官方效果图上的控件类似,效果图: 即焦点始终在屏幕中央,焦点选中的item被放大,且颜色被改变,遥控器可以指挥listview上下滚 ...

  5. android 焦点分发,Android TV 焦点分发原理解析

    前言 相信很多刚接触AndroidTV开发的开发者,都会被各种焦点问题给折磨的不行.不管是学技术还是学习其他知识,都要学习和理解其中原理,碰到问题我们才能得心应手.下面就来探一探Android的焦点分 ...

  6. Android TV 焦点分发原理解析

    前言 相信很多刚接触AndroidTV开发的开发者,都会被各种焦点问题给折磨的不行.不管是学技术还是学习其他知识,都要学习和理解其中原理,碰到问题我们才能得心应手.下面就来探一探Android的焦点分 ...

  7. android动画影子效果,Android TV常用动画的效果,View选中变大且有阴影(手机也能用)...

    因为电视屏幕比较大,而我们看电视时距离电视有一定距离,这样就需要动画效果比较明显,这个动画就是应用最广泛的,因为很酷,呵呵,你懂得,看了就知道. 效果如下图: public class MainAct ...

  8. 针对Android TV端使用的自定义RecyclerView

    在Android TV中开发, 需要处理焦点的移动, 为了达到醒目的作用一般都会添加焦点移动动画和焦点选中放大效果, 为了方便在TV端使用RecyclerView, 故自定义TvRecyclerVie ...

  9. Android TV Demo 工程,其中包含 TV 常用的自定义控件,飞框效果实现,外边框效果实现,UI 控件焦点自动处理,使 TV 开发更简单,更高效。

    TVLibraryDemo 项目地址:zhangtiansheng/TVLibraryDemo  简介:Android TV Demo 工程,其中包含 TV 常用的自定义控件,飞框效果实现,外边框效果 ...

最新文章

  1. 线性表的存储结构总结
  2. SpringBootController控制层接收参数的几种常用方式
  3. android应用程序开发_深圳app开发公司:跨平台应用程序开发工具有哪些?
  4. Druid使用ConfigFilter
  5. 蓝桥杯2018年第九届C/C++省赛A组第二题-星期一
  6. Kotlin 我的第一个kotlin程序【Android Studio】
  7. 有了它,Java语法也可以变得甜甜的
  8. 怎么用计算机算lg多少是一个数,数学lg怎么算
  9. redis源码阅读—hyperloglog(基数统计)
  10. 微信小程序学习笔记——环境准备 【注册账号】【获取APPID】
  11. 留在一线城市还是回老家?一个8年北漂的4点思考
  12. 软件测试技术什么是分支覆盖,分支覆盖率测试是什么?
  13. ABAP里面的OCCURS与HEADER LINE之间的一些区别
  14. 2022年品牌高考借势文案合集,拿走就能用,预祝各位考生金榜提名
  15. 电子计算机上gt键的功能,请问计算器里的GT键是做什么用的
  16. 【web前端特效源码】使用HTML5+CSS3+JavaScript制作一个复古手机键盘(带声音)的动画效果~~适合初学者~超简单~
  17. 《软件方法》第8章 分析 之 分析类图(2)
  18. 第 20 题:请描述一下 BFC、IFC、GFC 和 FFC 的区别?
  19. 数百家门店“联营管理” 鞋企瑞贝卡为何看重IMO班聊?
  20. 和陆琪一起侃一侃在这个看脸的世界,容貌改变命运

热门文章

  1. u盘装puppy linux,将PuppyLinux安装到U盘
  2. puppy linux 5.11中文集成清爽160m,中文Puppy Linux开发者之家
  3. [转] 一篇好文 ---steve jobs (stay hungry, stay foolish)
  4. php:::值传递战援引传递
  5. 树莓派4B安装系统,配置远程连接和WiFi,更新源,更新中文支持,基本Linux命令,用Python输出hello和“你好,世界”
  6. python二级考试报名多少钱_Python语言二级考试你准备好了吗?
  7. oa办公系统源码OA企业人事管理系统源码php协同自动化办公签到
  8. electron 应用程序updater实现热更新
  9. 计算机的智能计算方向,多媒体与智能计算研究方向
  10. proxy(初级运用)