2 lu22629438 lu22629438 于 2016.02.05 17:10 提问

gridview的item高度不同产生重叠,怎么解决

图片说明

1个回答

caozhy
caozhy   Ds   Rxr 2016.02.05 22:59

GridView中item高度自适应

 public class MyAdapter extends BaseAdapter {

    GridView mGv;   
  public static int ROW_NUMBER = 5;

  public MyAdapter (GridView gv, Context mContext, ArrayList<String> list) {
    this.context = mContext;
    this.mGv = gv;
    lstDate = list;
  }

     @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    convertView = LayoutInflater.from(context).inflate(R.layout.item, null);
    //高度计算
    AbsListView.LayoutParams param = new AbsListView.LayoutParams(
        android.view.ViewGroup.LayoutParams.FILL_PARENT,
        mGv.getHeight()/ROW_NUMBER);
    convertView.setLayoutParams(param);

    return convertView;
  }
lu22629438
lu22629438 这个也不行啊
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!