不可滑动的ListView (RecyclweView类似)
public class NoScrollListView extends ListView {
public NoScrollListView(Context context, AttributeSet attrs) {
super(context,attrs);
}
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
int mExpandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> , MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, mExpandSpec);
}
}
用于情况:
社交,社区APP ,例如 QQ空间,一条说说,说说下面的评论用不可滑动的ListView来展示
---------------------------------------------------------------------------------------------------------------------
不可滑动的GridView
public class NonScrollGridView extends GridView { public NonScrollGridView(Context context, AttributeSet attrs) {
super(context, attrs);
} public NonScrollGridView(Context context) {
super(context);
} public NonScrollGridView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
} @Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> , MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
用于情况:
多的是,APP各种分类 item