ImageView - have height match width?

后端 未结 14 2450
长发绾君心
长发绾君心 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:10

    For people passing by now, in 2017, the new best way to achieve what you want is by using ConstraintLayout like this:

    
    

    And don't forget to add constraints to all of the four directions as needed by your layout.

    Build a Responsive UI with ConstraintLayout

    Furthermore, by now, PercentRelativeLayout has been deprecated (see Android documentation).

提交回复
热议问题