简体   繁体   中英

How to disable or change color for black rows while ListView scrolling

Colleagues, please advice how can I or remove these black lines which appears on ListView scrolling (see screenshot) either disable them? 替代文字

To do it dynamically use the method .setVerticalFadingEdgeEnabled()

Or, in your XML Layout you can use the tag android:fadingEdge="none" (credit to nicky )

in android xml layout of scroll view

android:fadingEdge="none"

ad this

Please don't just turn this off. It is an important UI feature for the user to know there is more content above and/or below the list, and turning it off makes your UI behave inconsistently with the rest of the platform.

If you want to have a custom background color, the best way to do this is to make your own theme that sets it. This way when a preview is needed to be shown of your app it will better match your actual UI, and the theme will automatically take care of using this color for things like fades. Here is an example of what you could put in a res/values/styles.xml file, making such a theme which you can set for your application or an individual activity with android:theme="@style/CustomTheme" .

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="custom_theme_color">#b0b0ff</color>
    <style name="CustomTheme" parent="android:Theme.Light">
        <item name="android:windowBackground">@color/custom_theme_color</item>
        <item name="android:colorBackground">@color/custom_theme_color</item>
    </style>
</code>

(Sorry about the syntax being a little odd -- it is because android:windowBackground currently can only be given a reference to a resource, not a constant color.)

For a list of the attributes you can use when declaring a theme, see:

http://developer.android.com/reference/android/R.styleable.html#Theme

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM