3

I have a GriView in which every element is a card with rounded corners. At the top of it there's an ImageView loaded from the net. I would like to fit the image inside the card so that it will have the top corners rounded. I've tryied with layer-list background, but no result.

Here is an image to show what I want.

Is there anyone who can give me some hints?

Thanks in advance

Lorenzo Barbagli
  • 1,241
  • 2
  • 16
  • 34

2 Answers2

1

I found a solution: just put a rounded imageview (rectangle with rounded corners) behind the opaque relative layout (with same amount of rounded corners only in the bottom) and then set a negative bottom margin in the imageview, so that it will be covered for nearly 5 px by the relative layout

Lorenzo Barbagli
  • 1,241
  • 2
  • 16
  • 34
1

you can use this lib

and set this parameter for it:

<com.joooonho.SelectableRoundedImageView
    ...
    app:sriv_left_top_corner_radius="16dip"
    app:sriv_right_top_corner_radius="16dip"
    app:sriv_left_bottom_corner_radius="0dip"
    app:sriv_right_bottom_corner_radius="0dip"
    ...
    app:sriv_oval="false" />
hkh114
  • 162
  • 1
  • 3
  • 15