ImageView - have height match width?

后端 未结 14 2502
长发绾君心
长发绾君心 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 05:50

    I don't think there's any way you can do it in XML layout file, and I don't think android:scaleType attribute will work like you want it to be.
    The only way would be to do it programmatically. You can set the width to fill_parent and can either take screen width as the height of the View or can use View.getWidth() method.

提交回复
热议问题