阅读背景:

自定义listview 边缘效果

来源:互联网 
static void ChangeEdgeEffect(Context cxt, View list, int color){ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { EdgeEffect edgeEffectTop = new EdgeEffect(cxt); edgeEffectTop.setColor(color); EdgeEffect edgeEffectBottom = new EdgeEffect(cxt); edgeEffectBottom.setColor(color); try { Field f1 = AbsListView.class.getDeclaredField("mEdgeGlowTop"); f1.setAccessible(true); f1.set(list, edgeEffectTop); Field f2 = AbsListView.class.getDeclaredField("mEdgeGlowBottom"); f2.setAccessible(true); f2.set(list, edgeEffectBottom); } catch (Exception e) { e.printStackTrace(); } }else{ int glowDrawableId = cxt.getResources().getIdentifier("overscroll_glow", "drawable", "android"); Drawable androidGlow = cxt.getResources().getDrawable(glowDrawableId); assert androidGlow != null; androidGlow.setColorFilter(cxt.getResources().getColor(color), PorterDuff.Mode.SRC_ATOP); } } static void ChangeEdgeEffect(Context cxt, View lis


你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: