gridview中设置item的高度。
一、BaseAdapter中的getView中设置
AbsListView.LayoutParams param = new AbsListView.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, parent.getWidth()/2+DpPx.dip2px(context,20));//-20 10spacing 5padding + 40 textview.height convertView.setLayoutParams(param);
二、dp转px
public static int dip2px(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); }