美文网首页新样式Android知识Android技术知识
【Tips】Android 圆角图片+圆角边框效果

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

作者: 最爱平角裤 | 来源:发表于2017-05-19 15:12 被阅读267次

默认情况下图片的展示形式都是直角边,当然有时为了美观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>

以上

相关文章

网友评论

    本文标题:【Tips】Android 圆角图片+圆角边框效果

    本文链接:https://www.haomeiwen.com/subject/mweyxxtx.html