Scrollview & amp; RecycleView & amp; ListView & amp; Viewpager top/bottom shadow color change,

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.