简体   繁体   中英

Android image set height problems

I'm developing an android app which requires an imageview (and textviews) to be updated on button click, but I want the image to match the height of four of my textviews. When I set the height of the imageview, it seems to keep the height of the previous update, not the current one. Here is my code to update the image and its height.

int nameHeight = t_name.getHeight();
int timeHeight = r_time.getHeight();
int dateHeight = r_date.getHeight();
int locaHeight = r_loca.getHeight();
int totalHeight = nameHeight + timeHeight + dateHeight + locaHeight;

i_img.getLayoutParams().height = totalHeight;

Bitmap image = getBitmapFromURL(event_image.get(eventToUse));
i_img.setImageBitmap(image);

触摸布局参数后,调用requestLayout()以使更改生效。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM