i have recyclerview staggeredgridlayoutmanager. problem before full span element there gap need fill, increasing/decreasing height of last 2 elements. picture of problem:
- just 2 columns required.
- the elements of grid can have different heights.
i'm trying calculate height of 2 columns using each element height, , @ end see column longer, , add height shortest, don't know safe place set new height. when know sure height of view 1 going draw.
i'm stuck days problem, suggestions welcome!
onbindviewholder
double positionheight = getpositionratio(position); holder.img_event).setheightratio(positionheight); private double getpositionratio(final int position) { double ratio = spositionheightratios.get(position, 0.0); // if not yet done generate , stash columns height // in our real world scenario determined // match based on known height , width of image // , maybe helpful way column height! if (ratio == 0) { ratio = getrandomheightratio(); spositionheightratios.append(position, ratio); log.d("'", "getpositionratio:" + position + " ratio:" + ratio); } return ratio; } private final random mrandom = new random(); private double getrandomheightratio() { return (mrandom.nextdouble() / 2.0) + 1.0; // height 1.0 - 1.5 width }
Comments
Post a Comment