How to have a android:background color and still retain the gray focus highlight for lists in Android?

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How to have a android:background color and still retain the gray focus highlight for lists in Android?



I'm porting my app to Chrome OS and there are a few places in the app where arrow key navigation works, but the current focused element is not highlighted in any way. I've found that whenever I set a background color for an element like


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
...
android:background="@color/white" >

...

</LinearLayout>



then the default highlighting of the focused element will not show. Removing this will show the default background (which is not always the same as what I want).



Also, in cases where I use a selector in a ListView, the background is in front of the intended highlighting drawable (which can be seen if the color is somewhat transparent).


<?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>



This is even more strange since I was under the (possibly incorrect) impression that selectors will only pick one of the items.



I can't post too much code since this is work code, but this is happening throughout the app wherever there's a list.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

5,4XpVP54p CxKnxp,U2,fVyjvLNsq9cjPDY gay XVGJ PlvT8 sHG
Xm,bcjzbWK34LpVYB,7fApCwKUHZwxACrCDqH WXUSh4J UY kEkO,q8tg,j X73,85R3wH5XXPHhj g9,n7,N8v5BQ42Pn,jAhKelrp2Jr

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham