Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing focus indicator from RecycleView in Android

I have an app using RecyclerView, and on the tablet I get a light blue background showing. Particularly on Jelly Bean devices and in the emulator. 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. 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?

like image 607
chubbsondubs Avatar asked Jul 25 '16 02:07

chubbsondubs


1 Answers

That's the style of your recyclerView item. 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 what any color to show just give the same color to the focused state or try "@android:color/transparent".

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

like image 159
Joaquim Ley Avatar answered Oct 06 '22 23:10

Joaquim Ley