Wednesday, 15 April 2015

android - how to dynamically set imageView height based on its width -


See some image in a list row.

The number of imageViews in the row is different, that can be three or two images.

Height is, it should be 90% of the width of the image if the line has two image views, and 80% of the width, the row has three images.

Is there a way to do that in xml? If not, then how to set the height of the best place to do the cas and without the very upper part on the drawing? Thanks!

The best practice is to maintain the ratio between the height and the width: its definition of value in the DP With assets and other rap materials together.

In your case:

  android: layout_width = "20dp" Android: layout_heignt = "wrap_content"  

Should be adjusted according to the proportion of the given width.


No comments:

Post a Comment