Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Android list view 'blue' background

When I click on the list item in Android, I always get a blue background. Event if I use a custom layout, when I click, maybe 2-5dp space around my layout is blue. Also, the text views get darker. How can I disable any changes in view when clicking on the list item?

like image 767
lomza Avatar asked Jan 12 '12 15:01

lomza


2 Answers

I know its kind of late, but one can also use the setSelector method of the listview and set it to android.R.color.transparent. You can also use android:listSelector in the layout file to achieve the same result.

like image 82
Anand Sainath Avatar answered Oct 10 '22 21:10

Anand Sainath


Create custom theme for your application in /res/values/themes.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

  <!-- application theme -->
  <style name="CustomTheme" parent="android:style/Theme.Light">

    <!-- widget styles -->
    <item name="android:listViewStyle">@style/ListView</item>
  </style>

  <!-- list view -->
  <style name="ListView" parent="@android:style/Widget.ListView">
    <item name="android:background">#ffffff</item>
    <item name="android:cacheColorHint">#ffffff</item>
    <item name="android:divider">#cccccc</item>
    <item name="android:dividerHeight">1px</item>
    <item name="android:listSelector">@drawable/list_selector_background</item>
    <item name="android:fadingEdge">none</item>
  </style>

</resources>

In your AndroidManifest.xml specify the theme:

<application
    ...
    android:theme="@style/CustomTheme" >
like image 3
peceps Avatar answered Oct 10 '22 20:10

peceps