Android TV上的焦点凸显特效相信大家都看到过,那么我们就来实现它吧,首先上张效果图。
先说一下实现原理,主要通过重写RelativeLayout实现item,之后在其中加入scalanimation动画效果。刚开始处理时,还是发现了一些问题,比如item放大后会被其他item遮挡,如何添加选中边框等等,以及动画的实现等等。下面放上实现细节。
首先是item的代码:
<view xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item"
android:layout_width="@dimen/home_channel_item_width"
android:layout_height="@dimen/home_channel_item_height"
class="com.eastelsoft.tv.widget.home.HomeItemContainer"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:clipChildren="false"
android:clipToPadding="false" >
<com.eastelsoft.tv.widget.ESImageView
android:id="@+id/img"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/holder_nor"
android:duplicateParentState="true"
android:scaleType="fitXY" />
<!-- -->
<com.eastelsoft.tv.widget.ESImageView
android:id="@+id/hover"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="@string/desc"
android:duplicateParentState="true"
android:scaleType="fitXY"
android:src="@drawable/sl_image_home_navigator" />
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/home_item_text_margin"
android:layout_marginLeft="