I have a horizontal list
and each list item has a background fill view that
is supposed to be a certain percentage of the height of another view (bottleoverlay) inside the listview.
It all works except I can't find the height of the bottleoverlay view using getHeight()
as said in this question.
I've tried to use onGlobalLayout listener as suggested but the fill height for all items are the same no matter what values are used when setting layoutparams.height
Is there an easier way to do this, the bottleheightoverlay
is the same for each item in the list.
public class ImageAdapter extends BaseAdapter {
// varible declaration...
// getView that displays the data at the specified position in the data set.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
......
......
//increase height of filler
int bottleHeight = gridView.findViewById(R.id.bottleoverlay).getHeight();
FrameLayout backgroundfill = (FrameLayout) gridView.findViewById(R.id.backroundfillbar);
double percent = products.get(position).value/ products.get(0).value;
backgroundfill.getLayoutParams().height = (int) ( (bottleHeight/percent));