国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

glide中級進階

2019-11-09 17:40:00
字體:
來源:轉載
供稿:網友
一、glide和CircleImageView項目有沖突(直接使用glide切圓形即可)解決:放棄CircleImageView,直接使用glide切圓形。代碼:編寫了一個工具類。復制代碼即可//將圖片設置為圓形public static voidshowImage(finalContext context, String url, final ImageView imageview,Integer drawable) {if(null!=context){Glide.with(context).load(url).asBitmap().placeholder(drawable).centerCrop().fitCenter().error(drawable).into(newBitmapImageViewTarget(imageview) {@OverridePRotected voidsetResource(Bitmap resource) {RoundedBitmapDrawable circularBitmapDrawable =RoundedBitmapDrawableFactory.create(context.getResources(), resource);circularBitmapDrawable.setCircular(true);imageview.setImageDrawable(circularBitmapDrawable);}});}}二、安全的顯示gif圖片(考慮到url返回的可能不是gif)Glide .with( context ) .load( gifUrl ) .asGif() .error( R.drawable.full_cake ) .into( imageViewGif );3、不緩存圖片(glide默認是內存加磁盤緩存)Glide .with( context ) .load( eatFoodyImages[0] ) .diskCacheStrategy( DiskCacheStrategy.NONE ) .skipMemoryCache( true ) .into( imageViewInternet );skipMemoryCache( true ) 內存緩存diskCacheStrategy( DiskCacheStrategy.NONE ) 磁盤緩存 磁盤緩存需要枚舉而不是布爾DiskCacheStrategy.NONE 什么都不緩存,就像剛討論的那樣DiskCacheStrategy.SOURCE 僅僅只緩存原來的全分辨率的圖像。DiskCacheStrategy.RESULT 僅僅緩存最終的圖像,即,降低分辨率后的(或者是轉換后的)DiskCacheStrategy.ALL 緩存所有版本的圖像(默認行為)4、glide加載優先級比如:大將軍身邊有兩個小士兵,那么肯定優先展示將軍將更好看.很多時候,圖片是有先后順序的。可以使用一下枚舉Priority.LOWPriority.NORMALPriority.HIGHPriority.IMMEDIATE使用方式:高優先級:Glide .with( context ) .load( UsageExampleListViewAdapter.eatFoodyImages[0] ) .priority( Priority.HIGH ) .into( imageViewHero );低優先級:Glide .with( context ) .load( UsageExampleListViewAdapter.eatFoodyImages[0] ) .priority(Priority.LOW) .into( imageViewHero );5、如何用 Glide 旋轉圖片創建這個類:public class RotateTransformation extends BitmapTransformation { private float rotateRotationAngle = 0f; public RotateTransformation(Context context, float rotateRotationAngle) { super( context ); this.rotateRotationAngle = rotateRotationAngle; } @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { Matrix matrix = new Matrix(); matrix.postRotate(rotateRotationAngle); return Bitmap.createBitmap(toTransform, 0, 0, toTransform.getWidth(), toTransform.getHeight(), matrix, true); } @Override public String getId() { return "rotate" + rotateRotationAngle; }}使用方式:Glide .with( context ) .load( eatFoodyImages[0] ) .transform( new RotateTransformation( context, 90f )) .into( imageView3 );Bug:旋轉后(非90度,如45度),出現的出圖片外區域為黑色!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 肃宁县| 甘肃省| 阳城县| 县级市| 准格尔旗| 罗源县| 洛川县| 华亭县| 柳江县| 阿勒泰市| 阜阳市| 婺源县| 雷波县| 黔西县| 黄浦区| 郧西县| 丹江口市| 得荣县| 衡山县| 扎赉特旗| 巴林右旗| 定南县| 青海省| 南康市| 会泽县| 武山县| 泉州市| 江门市| 湄潭县| 梁平县| 海林市| 通许县| 莱州市| 高密市| 崇文区| 德惠市| 怀集县| 隆化县| 宜宾县| 阿坝| 祁门县|