默認(rèn)情況下圖片的展示形式都是直角邊忘伞,當(dāng)然有時(shí)為了美觀UI妹紙會(huì)設(shè)計(jì)出圓角的圖片展示,也許還會(huì)套上個(gè)圓角邊钞馁。如:
圖片圓角實(shí)現(xiàn)
項(xiàng)目中對(duì)圖片的加載采用的是Glide虑省。想要在展示的基礎(chǔ)上再進(jìn)行處理如圓角,圓形僧凰,高斯模糊等的效果需要借助這個(gè)庫(kù)glide-transformations探颈,只需要在into前調(diào)用bitmapTransform方法即可
Glide.with(getActivity()).load(item.getImgKey())
.bitmapTransform(new RoundedCornersTransformation(getActivity(),20,0))//設(shè)置圓角
.into(image);
其他效果參考:https://github.com/wasabeef/glide-transformations
圓角邊框
圓角邊框可以直接借助CardView中的cardCornerRadius進(jìn)行設(shè)置
邊框的顏色通過(guò)cardBackgroundColor
邊框的寬度通過(guò)子View的margin設(shè)置
<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>
以上