Skip to content Skip to sidebar Skip to footer

Creating Gridview With 3 Rows Of Imageviews That Fill The Whole Screen

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 vertically. Eac

Solution 1:

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();
}

Post a Comment for "Creating Gridview With 3 Rows Of Imageviews That Fill The Whole Screen"