How to create a background with Image, Rounded Corners without borders

后端 未结 6 1278
盖世英雄少女心
盖世英雄少女心 2020-12-20 05:29

I\'m trying to create a background for my LinearLayout that has an Image with rounded corners. I\'ve seen many examples how to do that but not exactly what I want. In most

6条回答
  •  攒了一身酷
    2020-12-20 05:59

    You can just use RoundedBitmapDrawable from Android Support Library v4. All you need is create an instance and set corner radius:

    RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap);
    final float roundPx = (float) bitmap.getWidth() * 0.06f;
    roundedBitmapDrawable.setCornerRadius(roundPx);
    

提交回复
热议问题