The article source 1:blog.csdn.net/janronehoo/…

listView.setCacheColorHint(0); Or Android :cacheColorHint=”#00000000″ to remove the drag background color from the ListView

If you do not use Android :cacheColorHint=”#00000000″, you will get a black background for the listView.

When you don’t use the Android :listSelector attribute, the default color of the selected item is orange and yellow. Sometimes we need to remove this effect:

\

  

Listview drag the background image to reveal 2013-07-19

123456789101112131415161718192021222324252627282930 <! -- The position of the last item flashes --> '              < ListView``                 android:id = "@+id/recommand_app_list"``                 android:layout_width = "fill_parent"``                 android:layout_height = "fill_parent"``                 android:layout_below = "@id/recommands_list_view_header_divider"``                 android:fadingEdge = "none"``                 android:scrollbars = "none"``                 android:scrollingCache = "true"  > ` ` </ ListView > ` `         <! -- Fixed bug where the last item was blinking --> '              < ListView``                 android:id = "@+id/recommand_app_list"``                 android:layout_width = "fill_parent"``                 android:layout_height = "fill_parent"``                 android:layout_below = "@id/recommands_list_view_header_divider"``                 android:background = "@drawable/ic_content_bg_repeat"``                 android:divider = "@drawable/ic_list_divider_repeat"``                 android:dividerHeight = "1dp"``                 android:fadingEdge = "none"``                 android:persistentDrawingCache = "none"``                 android:scrollbars = "none"``                 android:scrollingCache = "false"``                 android:smoothScrollbar = "true"  > ` ` </ ListView >

ListView is a frequently used Android control, now summary encountered some beautification of the small details.

1. When the listView is dragging, the background image disappears and becomes a black background. When the ListView is dragging, the background image is displayed

Solution: add to XML

Android: scrollingCache = “false” or android: cacheColorHint = “# 00000000”

2. The listView has black shadows above and below it

Solution: android: fadingEdge = “none”

Change the yellow background of the listView Item selection by default

Solution: Use the listView.setSelector () method in a Java file, or use the following code

1

Android :listSelector= “#00000000″// Write transparent, can also add Drawable image

4, lsitView between each item need to set a picture as an interval

Solution: android: divider = “@” drawable/list_driver”

Source 2: blog.csdn.net/liuhanhan51…

Remove the black shadow around the edges of the ListView when it slides to the top and bottom:

Xml code

  1. android:fadingEdge=”none”  

[xml]  view plain copy

  1. android:fadingEdge=”none”  

  

Remove the default black background when dragging:

Xml code

  1. android:cacheColorHint=”#00000000″  

[xml]  view plain copy

  1. android:cacheColorHint=”#00000000″  

 

Remove the yellow background color when selected:

Xml code

  1. android:listSelector=”#00000000″  

[xml]  view plain copy

  1. android:listSelector=”#00000000″  

Remove the black lines between lines:

Java code

  1. msgList.setDivider(null);  

[java]  view plain copy

  1. msgList.setDivider(null);  

The ListView automatically rolls to the bottom after refreshing:

Java code

  1. msgList.setSelection(msgList.getAdapter().getCount()-1);  

[java]  view plain copy

  1. msgList.setSelection(msgList.getAdapter().getCount()-1);  

Above, also can carry on custom color processing naturally.

Article source: www.cnblogs.com/loulijun/ar… \

Android Art Gallery — ListView changes the background color of the selected item

By default, the ListView background color is black, and the highlight color of the selected item is chrysanthemum yellow. In many cases, you have to define the background color or background image

Android: cacheColorHint = “@ android: color/transparent”, means to the black background, such as a ListView scroll will refresh the interface, the default color or color system, so set its transparency can adopt this way, This property is useful when setting up a ListView with a rounded image

Android: Divider =”@null” Used to remove the black lines between listView items

1. Background color

In list_ITEM_COLOR_bg.xml, the color can be set to a different color when clicking on the item. However, if color is used, the ListView cannot use the Android :listSelector attribute. If you set Android :listSelector, when you click on an item, the entire ListView will turn to one color, and you must set android: Background in the item. (Android :drawable=”@drawable/img”)

<? The XML version = "1.0" encoding = "utf-8"? > <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@color/green"></item> <item android:drawable="@color/white"></item> </selector>Copy the code

color.xml

<? The XML version = "1.0" encoding = "utf-8"? > <resources> <color name="white">#ffffff</color> <color name="black">#000000</color> <color name="green">#00ff00</color> </resources>Copy the code

Now look at the layout file

Listview.xml, in color, you can’t use listSelector here

<? The XML version = "1.0" encoding = "utf-8"? > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/lv" android:layout_width="fill_parent" android:layout_height="wrap_content" android:fastScrollEnabled="true" android:cacheColorHint="@android:color/transparent" android:divider="@null" /> </LinearLayout>Copy the code

List_item_color. XML, set the background directly in the layout of the item with the color setting

<? The XML version = "1.0" encoding = "utf-8"? > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:background="@drawable/list_item_color_bg">  <ImageView android:id="@+id/img" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" /> <TextView android:id="@+id/info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="14sp" /> </LinearLayout> </LinearLayout>Copy the code

rendering

2. Background image

And the way to do that is to set the background of the item with an image in the selector file, either android:listSelector for the ListView or Android :background for the item, But it’s better to use android:background, because using android:listSelector is the default image that’s set in the selector file below

<item android:drawable=”@drawable/login_input”/> Some strange, hope to understand can give directions

<? The XML version = "1.0" encoding = "utf-8"? > <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/input_over"/> <item android:drawable="@drawable/login_input"/> </selector>Copy the code

The listView is now set as follows: Android: Background is not set in item

<? The XML version = "1.0" encoding = "utf-8"? > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/lv" android:layout_width="fill_parent" android:layout_height="wrap_content" android:fastScrollEnabled="true" android:cacheColorHint="@android:color/transparent" android:listSelector="@drawable/list_item_drawable_bg" /> </LinearLayout>Copy the code

The background image is a.9. PNG image. Note that the default color is white

If you use Android :background, unselect Android :listSelector

\