How to dynamically change ImageView Height

后端 未结 2 1955
慢半拍i
慢半拍i 2021-01-13 01:28

I have a simple linear layout used for ListView\'s cell, and it has an imageview. The image will be downloaded from internet, so the size can be different sizes.

How

2条回答
  •  盖世英雄少女心
    2021-01-13 02:15

    The place where you are loading the imageView in the code from the url, you have to set the layout parameters of the ImageView over there. It will change the dimensions of the image dynamically.

    After loading the image find the dimensions and calculate the ratio and change the dimensions according to the condition you want to apply.

        LinearLayout.LayoutParams layoutParams  = new LinearLayout.LayoutParams(width,height);
        imageView.setLayoutParams(layoutParams);
        //set other properties of the imageview according to your condition
    

提交回复
热议问题