Removing the focus indicator from RecycleView in Android

I have an application using RecyclerView , and on the tablet I get a light blue background. In particular, on Jelly Bean devices and in the emulator. I tried removing it by marking my RecyclerView as android:focusable="false" . I know that this is a focus indicator, because on the emulator, if I hit the tab key, it leaves and highlights the button in the user interface. It does not appear on the phones that I used.

So why is this done on a touch device? And how do I get rid of it?

+7
android focus android-recyclerview
source share
1 answer

This is the style of your recyclerView element. Use 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 have which color shows only one color for a focused state, or try "@android:color/transparent" .

Then set android:background="@drawable/your_above_xml"

+1
source share

All Articles