Android TV 焦点框移动的实现方法焦点框移动的实现方法
本篇文章主要介绍了Android TV 焦点框移动的实现方法,小编觉得挺不错的,现在分享给大家,也给大家做个
参考。一起跟随小编过来看看吧
Tv开发,最重要的当然是焦点框的移动,有了焦点框我们才能知道当前选中的是哪一个,我们来看下效果图:
那它是怎么实现的呢,我们一起来看下。
原理原理
布局上使用一个view,背景是.9图片做焦点框,选中一个控件的时候把这个view移动选中的控件的位置。怎么样,是不是很简
单,行动起来。先看下布局
codeing
布局:布局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:background="@color/colorAccent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/id_fl"
android:layout_width="880dp"
android:layout_height="76dp"
android:layout_marginLeft="208dp"
android:layout_marginTop="9dp"
android:focusable="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="40dp"
android:text="第一行"
android:textSize="28sp" />
</FrameLayout>
<FrameLayout
android:id="@+id/id_fl_2"
android:layout_width="880dp"
android:layout_height="76dp"
android:layout_marginLeft="208dp"
android:layout_marginTop="9dp"
android:focusable="true">
评论0