Android GridView Remove Self-border Click Effect, remove right scroll bar, disable swipe up or down

Source: Internet
Author: User

First, remove the self-border click Effect:
1 <Com.example.gridview.MyGridView2             Android:id= "@+id/grid_upload_pictures"3 Android:layout_width= "0DP"4 Android:layout_weight= "2"5 Android:paddingleft= "20DP"6 android:listselector= "@android: Color/transparent"7 Android:layout_height= "Wrap_content"8 android:horizontalspacing= "10DP"9 android:verticalspacing= "10DP"Ten Android:numcolumns= "1" One Android:stretchmode= "ColumnWidth"/>

Second, remove the right scroll bar
1  PackageCom.example.gridview;2 3 ImportAndroid.content.Context;4 ImportAndroid.util.AttributeSet;5 6  Public classMyGridViewextendsAndroid.widget.GridView {7      PublicMyGridView (Context context, AttributeSet attrs) {8         Super(context, attrs);9     }Ten  One      PublicMyGridView (Context context) { A         Super(context); -     } -  the      PublicMyGridView (context context, AttributeSet attrs,intDefstyle) { -         Super(context, attrs, defstyle); -     } -     //The Onmeasure method of the GridView is overridden so that it does not appear in the scroll bar + @Override -      Public voidOnmeasure (intWidthmeasurespec,intHeightmeasurespec) { +         intExpandspec =Measurespec.makemeasurespec ( AInteger.max_value >> 2, measurespec.at_most); at         Super. Onmeasure (Widthmeasurespec, expandspec); -     } -}

Third, prohibit sliding up and down
1  PackageCom.example.gridview;2 3 ImportAndroid.content.Context;4 ImportAndroid.util.AttributeSet;5 6  Public classMyGridView2extendsandroid.widget.gridview{7   8      PublicHotkeygridview (context context, AttributeSet attrs,intDefstyle) {  9         Super(context, attrs, Defstyle); Ten     }   One    A      PublicHotkeygridview (Context context, AttributeSet attrs) { -         Super(context, attrs);  -     }   the    -      PublicHotkeygridview (Context context) { -         Super(context);  -     }   +    -    +      Public Booleandispatchtouchevent (motionevent ev) { A         if(ev.getaction () = =motionevent.action_move) {   at             return true;//prohibit the GridView from sliding -         }   -         return Super. dispatchtouchevent (EV);  -     }   -}

Thank:

http://blog.csdn.net/super11235/article/details/55050141

http://blog.csdn.net/go_to_learn/article/details/17761735

Android GridView Remove Self-border Click Effect, remove right scroll bar, disable swipe up or down

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.