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