Android ListView Common Configuration Instructions

Source: Internet
Author: User

The ListView is a control we often use, but in use for a variety of reasons can not set the effect we need, now the commonly used settings are recorded to facilitate later query.

1. The background turns black when dragging

Android:cachecolorhint= "#00000000"

2. Invalid after setting the Listselector

Android:drawselectorontop= "true"

3.listSelector indicates the selected background image, sometimes we need to set the pressed background (not checked), you need the following settings:

① first create an XML file under the Drawable folder and name it list_select:

<? XML version= "1.0" encoding= "Utf-8" ?> <  xmlns:android= "http://schemas.android.com/apk/res/android">     <android:state_pressed= "true"  android:drawable= "@ Drawable/activity_main_setting_press "/>    </selector> 

Activity_main_setting_press is the background image when pressed

② is quoted in the ListView as follows:

Android:listselector= "@drawable/list_select"

4. The above 3 description can also set the background color, such as:

<? XML version= "1.0" encoding= "Utf-8" ?> <  xmlns:android= "http://schemas.android.com/apk/res/android">     <android:state_pressed= "true"  android:drawable= "@color /gray "/>    </selector>

The above gray must be configured in the Values-colors file

5. After setting up as above 4, it is possible that the background or background can not be displayed to obscure the former text content, you need to check whether the ListView item item sets the background color, you must clear the background color.

Android ListView Common Configuration Instructions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.