[英]Removing focus indicator from RecycleView in Android
I have an app using RecyclerView
, and on the tablet I get a light blue background showing. 我有一个使用
RecyclerView
的应用程序,在平板电脑上我显示浅蓝色背景。 Particularly on Jelly Bean devices and in the emulator. 特别是在Jelly Bean设备和模拟器中。 I've tried to remove it by marking my
RecyclerView
as android:focusable="false"
I know it's the focus indicator since on the emulator if I hit the tab key it goes away and highlights a button on the UI. 我试图通过将我的
RecyclerView
标记为android:focusable="false"
来删除它android:focusable="false"
我知道它是焦点指示器,因为在模拟器上如果我按Tab键它会消失并突出显示UI上的按钮。 It doesn't show up on the phones I've used. 它没有出现在我用过的手机上。
So why is it being rendered on a touch device? 那么为什么它会在触摸设备上呈现呢? And how do I get rid of it?
我怎么摆脱它呢?
That's the style of your recyclerView item. 这就是您的recyclerView项目的风格。 Use
selectors
使用
selectors
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/pressedStateColor" />
<item android:state_focused="true" android:drawable="@color/focusedStateColor" />
<item android:drawable="@color/normalStateColor" />
</selector>
If you don't what any color to show just give the same color to the focused state or try "@android:color/transparent"
. 如果你没有显示任何颜色只是给焦点状态相同的颜色或尝试
"@android:color/transparent"
。
Then set your android:background="@drawable/your_above_xml"
然后设置你的
android:background="@drawable/your_above_xml"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.