【发布时间】:2011-02-08 02:41:21
【问题描述】:
我有一个白色背景的 Android 滚动视图。褪色边缘是白色半透明渐变。我想把它改成黑色而不是白色。我在同一个项目中有一个 ListView,其背景为白色,默认情况下具有黑色渐变边缘,但我找不到设置的位置(如果有的话)。
【问题讨论】:
标签: android scrollview fading
我有一个白色背景的 Android 滚动视图。褪色边缘是白色半透明渐变。我想把它改成黑色而不是白色。我在同一个项目中有一个 ListView,其背景为白色,默认情况下具有黑色渐变边缘,但我找不到设置的位置(如果有的话)。
【问题讨论】:
标签: android scrollview fading
如果你想要一个与背景不同的褪色边缘,你必须重写 ScrollView 的 getSolidColor() 方法。例如:
@Override
public int getSolidColor() {
return Color.rgb(0x30, 0x30, 0x30);
}
【讨论】:
只是通过反复试验发现的。
只需将android:background="@color/yourColor" 设置为<ScrollView>。它将阴影设置为给定的颜色。
【讨论】:
你可以使用:
final int glowDrawableId = context.getResources().getIdentifier("overscroll_glow",
"drawable", "android");
final Drawable androidGlow = context.getResources().getDrawable(glowDrawableId);
androidGlow.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
int edgeDrawableId = context.getResources().getIdentifier("overscroll_edge", "drawable",
"android");
final Drawable androidEdge = context.getResources().getDrawable(edgeDrawableId);
androidEdge.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
【讨论】:
【讨论】:
编辑:这没有回答问题,它要求ScrollView。此答案仅适用于AbsListView 及其后代(包括ListView)。
淡入淡出的边缘颜色由android:cacheColorHint 属性控制。
例如:
<ScrollView android:cacheColorHint="#ff000000" android:background="#ffffffff" />
将背景设置为白色,cacheColorHint 用于绘制褪色边缘颜色——在这种情况下,它将是黑色。
【讨论】:
如果您不知道是什么改变了褪色边缘的颜色,那可能是样式或主题的应用。在 Activity 中检查清单中的 android:theme="something"。如果主题来自android.R.style.Theme.Light 组,则边缘将为白色。默认的android.R.style.Theme 和android.R.style.Theme.Black 将有黑色褪色边缘。主题也会影响其他属性,因此在将它们投入其中之前,请全面检查这些属性。
【讨论】:
<!-- Variant of the default (dark) theme with no title bar --> 所以,您使用的是包含黑色褪色边缘的深色主题。你想要Theme.Light.NoTitleBar
这样做:
<ScrollView
android:theme="@style/scrollUpdate"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
在 values\styles 中放置样式
<style name="scrollUpdate">
<item name="colorAccent">@color/yourcolor</item>
<item name="android:color">@color/yourcolor</item>
<item name="colorPrimary">@color/yourcolor</item>
<item name="colorPrimaryDark">@color/yourcolor</item>
</style>
对我有用!
【讨论】: