Android programmatically sets the listview background with transparency issues
•
Android
My first question is, how to set the color of the listview background to white?
I tried list. Setbackgroundcolor (0xFFFFFF); But of course it doesn't work
Another problem I encounter in other list views (I can easily change BG in XML, but I don't know how to use it in Java) is that the line turns black when you click and scroll
I think this is the problem: Android listview background not painted
Again, I don't know how to implement it in my code
resolvent:
You can set the background color of listview as follows,
ListView listview=new ListView(this);
listview.setBackgroundColor(Color.WHITE);
If the list view displays black when you scroll through it, add some code to the XML
android:cacheColorHint="#00000000"
android:scrollbarFadeDuration="0"
I think it may help you
Edit:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/plainbg">
<ListView
android:id="@+id/foodlistview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:scrollbarFadeDuration="0"
android:divider="@android:color/white"
android:dividerHeight="2px"
></ListView>
The XML layout here contains listview. XML
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码