Scrollview & RecycleView & ListView & Viewpager top/bottom shadow color change,
Scrollview & RecycleView & ListView & Viewpager top/bottom shadow color change 0 Use topic settings
However, note that only api21 and above are supported.
The following methods are used to set reflection:
1 Scrollview
Two properties involvedMEdgeGlowTop,All mEdgeGlowBottomEdgeEffect type
Direct de-reflection to change color
Here we useMEdgeGlowTop
Field topMethod = ScrollView.class.getDeclaredField("mEdgeGlowTop");topMethod.setAccessible(true);EdgeEffect top = (EdgeEffect) topMethod.get(scrollView);if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { top.setColor(Color.RED);}
2 RecycleView
RecycleView has four attributes,mLeftGlow, mTopGlow, mRightGlow, mBottomGlow
Use andScrollview can be implemented in the same way
3 ListView
Listview hasPublic Method
/** * Sets the drawable that will be drawn above all other list content. * This area can become visible when the user overscrolls the list. * * @param header The drawable to use */ public void setOverscrollHeader(Drawable header) { mOverScrollHeader = header; if (mScrollY < 0) { invalidate(); } } /** * Sets the drawable that will be drawn below all other list content. * This area can become visible when the user overscrolls the list, * or when the list's content does not fully fill the container area. * * @param footer The drawable to use */ public void setOverscrollFooter(Drawable footer) { mOverScrollFooter = footer; invalidate(); }
4 viewpager
Viewpager also has two attributes: left and right, and the reflection method also applies.Scrollview, attribute:mLeftEdge,mRightEdge