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

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

glide中級進階

2019-11-09 18:42:50
字體:
來源:轉載
供稿:網友
一、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度),出現的出圖片外區域為黑色!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 濮阳县| 上思县| 八宿县| 汝阳县| 中卫市| 包头市| 西安市| 新昌县| 会宁县| 松原市| 芒康县| 鹤峰县| 信丰县| 锡林浩特市| 黑龙江省| 云龙县| 重庆市| 民勤县| 兴山县| 新田县| 元阳县| 双江| 阳新县| 南阳市| 房山区| 阿拉善右旗| 松江区| 满城县| 垣曲县| 将乐县| 株洲市| 遂宁市| 江源县| 彰武县| 南汇区| 信丰县| 大渡口区| 周至县| 罗山县| 开江县| 德格县|