Skip to content

Instantly share code, notes, and snippets.

@leelei
Forked from smallnewer/NoScrollGridView.java
Last active August 29, 2015 14:08
Show Gist options
  • Save leelei/2fd9671a678120eaed4a to your computer and use it in GitHub Desktop.
Save leelei/2fd9671a678120eaed4a to your computer and use it in GitHub Desktop.
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