public class MyGridView extends GridView {
private boolean haveScrollbar = true;
public MyGridView(Context context) {
super(context);
}
public MyGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyGridView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* Set whether there is a ScrollBar, and when it is to be displayed in the ScollView, it should be set to false. Default is true
*
* @param haveScrollbars
*/
public void setHaveScrollbar(boolean haveScrollbar) {
= haveScrollbar;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (haveScrollbars == false) {
int expandSpec = (Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
(widthMeasureSpec, expandSpec);
} else {
(widthMeasureSpec, heightMeasureSpec);
}
}
}