它是能够改变颜色的FadingEdge的一个列表视图?
题
我想要得到的影响,列表视图已经逐渐消失从任何其周围。通过默认设置为什么颜色你的列表视图。我可以调整的方向FadingEdge和大小的FadingEdge但不是颜色。这可能吗?
解决方案
当然可以!
setCacheColorHint(Color.WHITE);
其他提示
您将需要创建一个扩展的ListView一个新的类。
package com.mypackage;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
public class ColorFadeListView extends ListView
{
// fade to green by default
private static int mFadeColor = 0xFF00FF00;
public ColorFadeListView(Context context, AttributeSet attrs)
{
this(context, attrs,0);
}
public ColorFadeListView(Context context, AttributeSet attrs, int defStyle)
{
super(context,attrs,defStyle);
setFadingEdgeLength(30);
setVerticalFadingEdgeEnabled(true);
}
@Override
public int getSolidColor()
{
return mFadeColor;
}
public void setFadeColor( int fadeColor )
{
mFadeColor = fadeColor;
}
public int getFadeColor()
{
return mFadeColor;
}
}
您可以采用相同使用此列表视图正常ListView
(但你必须正确地投它使用fadeColor存取方法)。在XML,而不是定义一个对象作为<ListView android:properties.../>
把它定义为<com.mypackage.ColorFadeListView android:properties.../>
你可以试试这个(这是一个黑客的,我知道):
int glowDrawableId = context.getResources().getIdentifier("overscroll_glow", "drawable", "android");
Drawable androidGlow = context.getResources().getDrawable(glowDrawableId);
androidGlow.setColorFilter(brandColor, PorterDuff.Mode.MULTIPLY);
我利用了这一事实,即发光效果实际上是一个共同绘制和应用一个过滤器上: http://evendanan.net/android/branding/2013/12/09/branding-edge-effect/
不隶属于 StackOverflow