array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } 111string(0) "" int(1) int(10) int(70) int(8640000) string(13) "likecs_art_db" array(1) { ["query"]=> array(1) { ["match_all"]=> object(stdClass)#29 (0) { } } } array(1) { ["createtime.keyword"]=> array(1) { ["order"]=> string(4) "desc" } } int(10) int(0) int(8640000) array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } Glide加载圆角图片不显示问题 - 爱码网

近来项目里碰到个问题,那就是用Glide加载图片的时候圆角图片的问题.

请先看图片

Glide加载圆角图片不显示问题

首先图一图二图三的控件大小设置都是一样的

图一就是ImageView什么都不设置直接加载可以显示图片的圆角,但是呢有个问题就是设置的图片大小并不是那么大,单个显示的时候并没什么问题,但是放到RecyclerView会很难看

图二图三设置了ImageView的  android:scaleType="centerCrop"

图二 图片大小正常了但是圆角没有了

图三经过处理以后大小正常 圆角也显示了

废话不多说直接上代码:

 RequestOptions roundOptions = new RequestOptions()
                .transform(new RoundedCorners(30));
        //加载第一个图片
        Glide.with(this)
                .load(R.mipmap.ic_test)
                .apply(roundOptions)
                .into(ivActivityGlideRound);
        //加载第二个图片
        Glide.with(this)
                .load(R.mipmap.ic_test)
                .apply(roundOptions)
                .into(ivActivityGlideRoundCenterCrop);
        roundOptions.transform(new CenterCrop(), new RoundedCorners(30));//处理CenterCrop的情况
        //加载第三个图片
        Glide.with(this)
                .load(R.mipmap.ic_test)
                .apply(roundOptions)
                .into(ivActivityGlideRoundCenterCropResult);

完事儿收工

Demo传送门:ProjectDemos

 

相关文章: