Set size of ImageView in px at runtime

前端 未结 2 1708
星月不相逢
星月不相逢 2021-01-16 22:55

I want to put 8 image thumbs in one horizontal line, using the whole available width.
The images are retrieved from a webservice which lets me specify the dimensions.

2条回答
  •  渐次进展
    2021-01-16 23:30

    Add the ImageViews with a fixed size, i.e.:

    thumbs.addView (iv, new LayoutParams(thumbSize, thumbSize));
    

    To answer (partially) the questions in the comments:

    The ImageView API says:

    takes care of computing its measurement from the image so that it can be used in any layout manager

    so it is probably assuming 60px for a 160 dpi (I may be wrong there).

提交回复
热议问题