Creating gridview with 3 rows of imageviews that fill the whole screen

前端 未结 1 378
自闭症患者
自闭症患者 2021-01-16 03:17

I have been searching everywhere for similar solutions but none seem to work for me.

On my first screen I will have a gridview which consists of 1 column and 3 rows

相关标签:
1条回答
  • 2021-01-16 04:04

    Dynamically set the layout params of your imageview, once you know the height of the screen.

    if (row == null) {
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);
        //row.setMinimumHeight(MainActivity.height1/3);  //don't need this, since wrap content will make the row height match your image view's
    
        holder = new RecordHolder();
        holder.txtTitle = (TextView) row.findViewById(R.id.item_text);
        holder.imageItem = (ImageView) row.findViewById(R.id.item_image);
    
        holder.imageItem.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, MainActivity.height1/3);
        row.setTag(holder);
    } else {
        holder = (RecordHolder) row.getTag();
    }
    
    0 讨论(0)
提交回复
热议问题