Make ImageView fit width of CardView

前端 未结 10 685
太阳男子
太阳男子 2020-12-04 11:00

I have a CardView with rounded corners, I want to have an ImageView at the top like shown in the example taken from the material design guidelines

10条回答
  •  感情败类
    2020-12-04 11:35

    If your image size (width) is fixed with your ImageView width, you just only have to do is change your ImageView attribute to :

    android:scaleType="fitXY"
    

    That is. No additional image corner rounding, no busy work. Beside it efficient for app's performance.

    Note : my suggestion may not appropriate for small image with large size ImageView.

提交回复
热议问题