简体   繁体   English

ListView滚动时如何禁用或更改黑色行的颜色

[英]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? 同事们,请提出建议,我该如何删除在ListView滚动条上显示的黑线(请参阅屏幕截图)或将其禁用? 替代文字

To do it dynamically use the method .setVerticalFadingEdgeEnabled() 要动态地使用方法.setVerticalFadingEdgeEnabled()

Or, in your XML Layout you can use the tag android:fadingEdge="none" (credit to nicky ) 或者,在XML布局中,您可以使用标签android:fadingEdge="none" (贷记为nicky

in android xml layout of scroll view 在滚动视图的android xml布局中

android:fadingEdge="none" 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. 对于用户来说,这是一项重要的UI功能,它可以知道列表上方和/或下方还有更多内容,而将其关闭会使您的UI与平台的其余部分行为不一致。

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" . 这是您可以放入res / values / styles.xml文件中的示例,使您可以通过android:theme="@style/CustomTheme"为应用程序或单个活动设置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.) (很抱歉,语法有点奇怪-这是因为android:windowBackground当前只能提供对资源的引用,而不是恒定的颜色。)

For a list of the attributes you can use when declaring a theme, see: 有关在声明主题时可以使用的属性的列表,请参见:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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