国产探花免费观看_亚洲丰满少妇自慰呻吟_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度),出現的出圖片外區域為黑色!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 潼关县| 阿勒泰市| 临夏市| 兴隆县| 通道| 铜山县| 廉江市| 威海市| 桂阳县| 南平市| 富蕴县| 宁化县| 南木林县| 旬阳县| 莱西市| 通辽市| 白河县| 尼勒克县| 崇文区| 拉萨市| 广南县| 山丹县| 乐亭县| 乌鲁木齐县| 中江县| 道真| 北碚区| 昌图县| 财经| 常山县| 南木林县| 山西省| 永新县| 包头市| 勃利县| 桦甸市| 临沧市| 天门市| 永吉县| 嘉兴市| 囊谦县|