Background ListView becomes black when scrolling
Add an attribute on the ListView
Tag
android:cacheColorHint="#00000000" // setting transparent color
For more details check this blog
My ListView backgrounds go black during scrolling - how to fix?
You will need to use the setCacheColorHint()
method of ListView.
Example: list.setCacheColorHint(yourBackColor);
Explanation of the issue and solution here
List color turns black while Scrolling
Add this to listView
in the xml file:
android:cacheColorHint="#00000000"
or in Java code:
getListView().setCacheColorHint(0);
Android ListView Background Color Changes on Scroll - colorCacheHint Not Fixing Issue
Could you try setting the cachecolorhint in the xml where the Listview is declared, instead of the LinearLayout :
At layout file, use:
android:cacheColorHint="#0000"
OR at java code,use
listView.setCacheColorHint(Color.TRANSPARENT);
Hope this helps!!
List items becomes black during scroll, setCacheColorHint() takes no effect
In order to make alternate background color for list item . In your adapter class write this line of code
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
ViewHolder holder;
if (v == null) {
LayoutInflater vi = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.listitem, null);
if (position % 2 == 0) {
v.setBackgroundResource(R.color.firstcolor);
} else {
v.setBackgroundResource(R.color.second color);
}
...............
.........
Hi
For complete help go through my Android Blog hope you will find your answer as you are looking for. Just now i have done from my side and tested, its working fine for me.
At the bottom you will get a link so that you can download full source code.
http://amitandroid.blogspot.in/2013/03/android-listview-with-alternate-list.html
Please let me know if it full fill your requirement.
ListView element background color changes to black while scrolling
In my case this works fine
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dip"
android:layout_weight="1"
android:background="#ffffff"
android:choiceMode="singleChoice"
android:cacheColorHint="@android:color/transparent"
android:scrollingCache="false"
android:fastScrollEnabled="true">
</ListView>
One of the developer says, you have to use these 2 properties compulsory..
android:cacheColorHint="@android:color/transparent"
android:scrollingCache="false"
Related Topics
Scale Image to Fill Imageview Width and Keep Aspect Ratio
Install_Failed_Update_Incompatible When I Try to Install Compiled .Apk on Device
How to Set Relativelayout Layout Params in Code Not in Xml
Passing String Array Between Android Activities
Android M Permissions:Confused on the Usage of Shouldshowrequestpermissionrationale() Function
Securityexception: Caller Uid Xxxx Is Different Than the Authenticator's Uid
Android Webview App Won't Let Video Player Go Full Screen
Reading a Specific File from Sdcard in Android
Draw Overlay in Android (System Wide)
Disabling of Edittext in Android
How Does the Mapping Between Android Resources and Resources Id Work
How to Display Custom View in Actionbar
Android Design Support Library for API 28 (P) Not Working
Gles10.Glgetintegerv Returns 0 in Lollipop Only
Fade in Fade Out Android Animation in Java
Continue Service Even If Application Is Cleared from Recent App