ListView ViewPager ScrollView modifies the boundary color, viewpagerscrollview
If it is difficult to see the shadow color of the default listview sliding to the top or bottom of android, you can define it as follows:
First look
public class ListView extends android.widget.ListView { private OnScrollListener mLegacyOnScrollListener; private final MulticastOnScrollListener mMulticastOnScrollListener = new MulticastOnScrollListener(); public ListView(Context context) { this(context, null); } public ListView(Context context, AttributeSet attrs) { this(context, attrs, android.R.attr.listViewStyle); } public ListView(Context context, AttributeSet attrs, int defStyle) { super(new ContextWrapperEdgeEffect(context), attrs, defStyle); init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { int color = context.getResources().getColor(R.color.default_edgeeffect_color); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EdgeEffectView, defStyle, 0); color = a.getColor(R.styleable.EdgeEffectView_edgeeffect_color, color); a.recycle(); } setEdgeEffectColor(color); } public void setOnScrollListener(OnScrollListener listener) { if (listener != null) { checkPrecondition(mLegacyOnScrollListener == null); mLegacyOnScrollListener = listener; addOnScrollListener(mLegacyOnScrollListener); } else if (mLegacyOnScrollListener != null) { removeOnScrollListener(mLegacyOnScrollListener); mLegacyOnScrollListener = null; } } public void setEdgeEffectColor(int edgeEffectColor) { ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(edgeEffectColor); } public void addOnScrollListener(OnScrollListener listener) { mMulticastOnScrollListener.add(listener); } public void clearOnScrollListeners() { mMulticastOnScrollListener.clear(); } public void removeOnScrollListener(OnScrollListener listener) { mMulticastOnScrollListener.remove(listener); } void checkPrecondition(boolean state) { if (!state) { throw new IllegalStateException(); } }}You can directly use it in xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ListViewActivity"> <uk.co.androidalliance.edgeeffectoverride.ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent" app:edgeeffect_color="@color/green"/></RelativeLayout>
Custom property File
<?xml version="1.0" encoding="utf-8"?><resources> <declare-styleable name="EdgeEffectView"> <attr name="edgeeffect_color" format="color"/> </declare-styleable></resources>
Similar to Viewpager scrollview
Refer to Demo