Question

I would like to obtain ImageView dimensions during bindView method.

Unfortunately during bindView measured height and width are 0.

I need those dimensions to request specific image width and height from web.

Was it helpful?

Solution

Before your AdapterView starts recycling views, the views would have not been layered-out on the screen yet, so they will be width and height of zero, because it really is zero.

After your bindView starts to receive recycled views, they will have width and height, but then it's too late.

On those situations you must find a different way to calculate their size, for example, you can make it be a fixed value in DP for every view and just use that value. Example:

int size = context.getResources().getDimensionPixelSize(R.dimen.img_size);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top