【Tips】Android 圆角图片+圆角边框效果

默认情况下图片的展示形式都是直角边,当然有时为了美观UI妹纸会设计出圆角的图片展示,也许还会套上个圆角边。如:

图片圆角实现

项目中对图片的加载采用的是Glide。想要在展示的基础上再进行处理如圆角,圆形,高斯模糊等的效果需要借助这个库glide-transformations,只需要在into前调用bitmapTransform方法即可

Glide.with(getActivity()).load(item.getImgKey())
     .bitmapTransform(new RoundedCornersTransformation(getActivity(),20,0))//设置圆角
     .into(image);

其他效果参考:https://github.com/wasabeef/glide-transformations

圆角边框

圆角边框可以直接借助CardView中的cardCornerRadius进行设置
边框的颜色通过cardBackgroundColor
边框的宽度通过子View的margin设置

    <android.support.v7.widget.CardView
        android:id="@+id/cv_select"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:cardBackgroundColor="@color/base_white"
        app:cardCornerRadius="5dp"
        app:cardElevation="0dp">

        <ImageView
            android:id="@+id/img_select_content"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="2dp"
            android:scaleType="fitXY" />

    </android.support.v7.widget.CardView>

以上

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容