国产探花免费观看_亚洲丰满少妇自慰呻吟_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度),出現的出圖片外區域為黑色!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蚌埠市| 阿克| 金湖县| 九龙县| 界首市| 弋阳县| 临城县| 灵石县| 雷州市| 邵武市| 大丰市| 平顶山市| 河东区| 宜春市| 玉门市| 华安县| 蚌埠市| 逊克县| 永新县| 都安| 康平县| 宁夏| 建德市| 宜黄县| 清原| 中西区| 江永县| 嘉兴市| 攀枝花市| 沂南县| 防城港市| 巴林左旗| 开阳县| 琼海市| 汶川县| 潮州市| 上蔡县| 北辰区| 大余县| 嘉峪关市| 余庆县|