ImageView - have height match width?

后端 未结 14 2458
长发绾君心
长发绾君心 2020-12-02 05:17

I have an imageview. I want its width to be fill_parent. I want its height to be whatever the width ends up being. For example:



        
14条回答
  •  伪装坚强ぢ
    2020-12-02 06:04

    Update: Sep 14 2017

    According to a comment below, the percent support library is deprecated as of Android Support Library 26.0.0. This is the new way to do it:

    
    
        
    
    
    

    See here

    Deprecated:

    According to this post by Android Developers, all you need to do now is to wrap whatever you want within a PercentRelativeLayout or a PercentFrameLayout, and then specify its ratios, like so

    
    
        
    
    
    

提交回复
热议问题