Listview uses overscroll to solve the problem of shadow and custom pattern on the border when pulling up and down. listviewoverscroll

Source: Internet
Author: User

Listview uses overscroll to solve the problem of shadow and custom pattern on the border when pulling up and down. listviewoverscroll


The following code must be available after 2.3 .. Now it's almost over 2.3 ..

Http://blog.csdn.net/wanghao200906/article/details/42004007

First, let's take a look at the default listview drop-down.


This is the Blue Shadow part. Let's talk about how to remove him first .. You can use only one line of code.

play_listview.setOverScrollMode(android.view.View.OVER_SCROLL_NEVER);
In this way, you can remove the shadow ..

Next we will introduce some high-end products .. Change the Blue Shadow and program the Blue Shadow ..




You can directly use the following methods ..

@ SuppressWarnings ("deprecation") public void setEdge (ListView lv) throws Exception, IllegalAccessException {Class <?> C = (Class <?>) Class. forName (AbsListView. class. getName (); Field egtField = c. getDeclaredField ("mEdgeGlowTop"); Field egbBottom = c. getDeclaredField ("mEdgeGlowBottom"); egtField. setAccessible (true); egbBottom. setAccessible (true); Object egtObject = egtField. get (lv); // this indicates the ListiVew Instance Object egbObject = egbBottom. get (lv); // egtObject. getClass () is actually an EdgeEffect with two important attributes: mGlow mEdge // and both attributes are Drawable Class <?> Cc = (Class <?>) Class. forName (egtObject. getClass (). getName (); Field mGlow = cc. getDeclaredField ("mGlow"); mGlow. setAccessible (true); mGlow. set (egbObject, new ColorDrawable (Color. RED); mGlow. set (egtObject, this. getResources (). getDrawable (R. drawable. ic_launcher); // mGlow. setBoolean (egtObject, false); // cancel displaying Field mEdge = cc. getDeclaredField ("mEdge"); mEdge. setAccessible (true); mEdge. set (egtObject, new ColorDrawable (Color. RED); mEdge. set (egbObject, new ColorDrawable (Color. RED ));}

Upload the listview. You can .. Note that there are two parameters.

Two layers can be found whether sliding down or sliding up ..

The above layer of mGlow

The lower layer of mEdge ..

In this way, the effect can be achieved ..






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.