1

有人知道如何让 state_hovered 在 GoogleTv 上被识别吗?我意识到这是 14 级 Android 4.0 的新功能,所以我原以为电视也会识别它。这是我的布局和 xml 选择器:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="50dp"
  android:layout_height="100dp"
  android:orientation="vertical"> 

    <Button 
        android:id="@+id/zoom_in"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@xml/zoom_in_selector" />

    <Button 
        android:id="@+id/zoom_out"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@xml/zoom_out_selector" />

</LinearLayout> 


<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
          android:drawable="@drawable/plus_downpressed" /> <!-- pressed -->
    <item android:state_focused="true"
          android:drawable="@drawable/plus_highlight" /> <!-- focused -->
    <item android:state_hovered="true"
          android:drawable="@drawable/plus_highlight" /> <!-- hovered -->
    <item android:state_pressed="false"
          android:drawable="@drawable/plus" /> <!-- default -->
</selector>
4

1 回答 1

1

Google TV is currently API 12, not 14. So, it's not possible. That said, you can use onGenericMotion event in code to implement hover.

于 2011-12-02T23:18:31.600 回答