Skip to content

Instantly share code, notes, and snippets.

@smallnewer
Created October 13, 2014 03:23
Show Gist options
  • Save smallnewer/960cee28679f19308d4e to your computer and use it in GitHub Desktop.
Save smallnewer/960cee28679f19308d4e to your computer and use it in GitHub Desktop.
为了修复GridView在wrap_content下只显示一半的问题
package com.example.fixview;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;
/**
* Created by new on 14-10-13.
* 纯粹是为了修复GridView在wrap_content下只显示一半的问题
*/
public class NoScrollGridView extends GridView {
public NoScrollGridView(Context context) {
super(context);
}
public NoScrollGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment