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?
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" >
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.
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" >
You can simply set the android drawSelectorOnTop attribute to false on your ListView and there will not be any background when you click on an item.
Eg:
<ListView android:layout_width="fill_parent" android:layout_height="fill_parent"
android:drawSelectorOnTop="false"/>
Use this
<ListView
android:listSelector="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
/>
For more details you can visit here
http://developer.android.com/reference/android/widget/ListView.html
I did it Like this:
<ListView
android:listSelector="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
© 2022 - 2024 — McMap. All rights reserved.
When I click on the list item in Android, I always get a blue background
. blue background for what? the listView or the listView item you're clicking? – Panter