Android GridView去除自带边框点击效果去除右侧滚动条禁止上下滑动

听闻少年二字,当与平庸相斥。这篇文章主要讲述Android GridView去除自带边框点击效果去除右侧滚动条禁止上下滑动相关的知识,希望能为你提供帮助。
一、去除自带边框点击效果:

1 < com.example.gridview.MyGridView 2android:id="@+id/grid_upload_pictures" 3android:layout_width="0dp" 4android:layout_weight="2" 5android:paddingLeft="20dp" 6 android:listSelector="@android:color/transparent" 7android:layout_height="wrap_content" 8android:horizontalSpacing="10dp" 9android:verticalSpacing="10dp" 10android:numColumns="1" 11android:stretchMode="columnWidth"/>

 
二、去除右侧滚动条
1 package com.example.gridview; 2 3 import android.content.Context; 4 import android.util.AttributeSet; 5 6 public class MyGridView extends android.widget.GridView { 7public MyGridView(Context context, AttributeSet attrs) { 8super(context, attrs); 9} 10 11public MyGridView(Context context) { 12super(context); 13} 14 15public MyGridView(Context context, AttributeSet attrs, int defStyle) { 16super(context, attrs, defStyle); 17} 18//重写了GridView的onMeasure方法,使其不会出现滚动条 19@Override 20public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 21int expandSpec = MeasureSpec.makeMeasureSpec( 22Integer.MAX_VALUE > > 2, MeasureSpec.AT_MOST); 23super.onMeasure(widthMeasureSpec, expandSpec); 24} 25 }

 
 
三、禁止上下滑动
1 package com.example.gridview; 2 3 import android.content.Context; 4 import android.util.AttributeSet; 5 6 public class MyGridView2 extends android.widget.GridView{ 7 8public HotKeyGridView(Context context, AttributeSet attrs, int defStyle) { 9super(context, attrs, defStyle); 10} 11 12public HotKeyGridView(Context context, AttributeSet attrs) { 13super(context, attrs); 14} 15 16public HotKeyGridView(Context context) { 17super(context); 18} 19 20 21public boolean dispatchTouchEvent(MotionEvent ev) { 22if(ev.getAction() == MotionEvent.ACTION_MOVE){ 23return true; //禁止Gridview进行滑动 24} 25return super.dispatchTouchEvent(ev); 26} 27 }

 
 
感谢:http://blog.csdn.net/super11235/article/details/55050141
【Android GridView去除自带边框点击效果去除右侧滚动条禁止上下滑动】http://blog.csdn.net/go_to_learn/article/details/17761735

    推荐阅读