I need to change the image in an imageview then get the width. Problem is, it gives me the width of the last image.
headpic.setImageResource(head[x]);
int width = headpic.getWidth();
if i then run this code again with x being the same value it gets the correct width.
I'm assuming headpic is your imageview. If so, wouldn't headpic.getWidth();
be getting the width of the imageview instead of the image?
You could get the drawable from the imageview and use .getIntrinsicWidth();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.