GridView在電視上注意事項
阿新 • • 發佈:2018-12-05
1、android:focusable="true"
<GridView android:id="@+id/gv_device" android:layout_width="match_parent" android:layout_height="match_parent" android:numColumns="3" android:horizontalSpacing="20dp" android:verticalSpacing="50dp" android:layout_margin="50dp" android:focusable="true" />
2、item selector
state_selected尤為重要,上下左右切換就靠這個屬性
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:drawable="@mipmap/xuanzhe"></item> <item android:state_pressed="true" android:drawable="@mipmap/xuanzhe"></item> <item android:state_selected="true" android:drawable="@mipmap/xuanzhe"></item> </selector>