我想给出 ListView 已经从它周围的任何东西中消失的效果。默认情况下,它设置为您的 ListView 的任何颜色。我可以调整 FadingEdge 的方向和 FadingEdge 的大小,但不能调整颜色。可能吗?
问问题
6976 次
3 回答
14
您需要创建一个扩展 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.../>
于 2011-05-04T02:32:15.827 回答
5
是的你可以 !
setCacheColorHint(Color.WHITE);
于 2010-10-29T11:59:26.013 回答
0
你可以试试这个(这是一个黑客,我知道):
int glowDrawableId = context.getResources().getIdentifier("overscroll_glow", "drawable", "android");
Drawable androidGlow = context.getResources().getDrawable(glowDrawableId);
androidGlow.setColorFilter(brandColor, PorterDuff.Mode.MULTIPLY);
我利用了发光效果实际上是一个共享的 Drawable 并在其上应用了过滤器这一事实:http ://evendanan.net/android/branding/2013/12/09/branding-edge-effect/
于 2013-12-09T19:28:29.880 回答