我正在将我的应用程序移植到 Chrome 操作系统,应用程序中有几个地方可以使用箭头键导航,但当前的焦点元素没有以任何方式突出显示。我发现每当我为像这样的元素设置背景颜色时
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
...
android:background="@color/white" >
...
</LinearLayout>
那么焦点元素的默认突出显示将不会显示。删除它会显示默认背景(这并不总是与我想要的相同)。
此外,在我在 ListView 中使用选择器的情况下,背景位于预期的突出显示可绘制对象的前面(如果颜色有点透明,则可以看到)。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime" >
<item android:state_pressed="false" android:state_focused="true" android:drawable="@drawable/list_focused" />
<item android:state_pressed="true" android:drawable="@drawable/list_pressed" />
<item android:drawable="@color/white" />
</selector>
这更奇怪,因为我(可能不正确)的印象是选择器只会选择其中一项。
我不能发布太多代码,因为这是工作代码,但是这会在整个应用程序中发生,只要有列表。