Scaling an image to max available width, keeping aspect ratio and avoiding ImageView extra space

后端 未结 6 2096
后悔当初
后悔当初 2021-02-04 03:07

I have this simple layout XML, and a green_square.png file which is 30X30 pixels




        
6条回答
  •  无人共我
    2021-02-04 04:02

    There lots of great answers here which actually works. I just what to share the way I do this now with a more modern XML syntax, the constraint view. Trust me constraint view rooks!

    
    
        
    
    
    
    

    of course the tools:context="com.collectsavings.collect.collectpro.LoginAndRegisterPrompt" and android:src="@drawable/green_square" Should all match your app activity context and drawabl resources respectively.

提交回复
热议问题