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

图片说明

1个回答

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
2005Liverpool 这个也不行啊
4 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐