第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用滑行將圖像下載到位圖中?

如何使用滑行將圖像下載到位圖中?

DIEA 2019-12-11 13:09:04
ImageView使用Glide 將網(wǎng)址下載到中非常容易:Glide   .with(context)   .load(getIntent().getData())   .placeholder(R.drawable.ic_loading)   .centerCrop()   .into(imageView);我想知道是否也可以下載到中Bitmap?我想下載到原始位圖中,然后可以使用其他工具進行操作。我已經(jīng)看過代碼,看不到該怎么做。
查看完整描述

3 回答

?
jeck貓

TA貢獻1909條經(jīng)驗 獲得超7個贊

確保您使用的是最新版本


implementation 'com.github.bumptech.glide:glide:4.9.0'


科特林:


Glide.with(this)

        .asBitmap()

        .load(imagePath)

        .into(object : CustomTarget<Bitmap>(){

            override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {

                imageView.setImageBitmap(resource)

            }

            override fun onLoadCleared(placeholder: Drawable?) {

                // this is called when imageView is cleared on lifecycle call or for

                // some other reason.

                // if you are referencing the bitmap somewhere else too other than this imageView

                // clear it here as you can no longer have the bitmap

            }

        })

位圖大?。?/p>


如果要使用圖像的原始大小,請使用上面的默認構(gòu)造函數(shù),否則可以將所需的大小傳遞給位圖


into(object : CustomTarget<Bitmap>(1980, 1080)


Java:


Glide.with(this)

        .asBitmap()

        .load(path)

        .into(new CustomTarget<Bitmap>() {

            @Override

            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {

                imageView.setImageBitmap(resource);

            }


            @Override

            public void onLoadCleared(@Nullable Drawable placeholder) {

            }

        });

舊答案:


隨著 compile 'com.github.bumptech.glide:glide:4.8.0'以下


Glide.with(this)

        .asBitmap()

        .load(path)

        .into(new SimpleTarget<Bitmap>() {

            @Override

            public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {

                imageView.setImageBitmap(resource);

            }

        });

對于compile 'com.github.bumptech.glide:glide:3.7.0'及以下


Glide.with(this)

        .load(path)

        .asBitmap()

        .into(new SimpleTarget<Bitmap>() {

            @Override

            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {

                imageView.setImageBitmap(resource);

            }

        });

現(xiàn)在您可能會看到一個警告 SimpleTarget is deprecated


原因:


棄用SimpleTarget的主要目的是警告您誘使您違反Glide的API合同的方式。具體來說,一旦清除SimpleTarget,它并不會迫使您停止使用已加載的任何資源,這可能導致崩潰和圖形損壞。


將SimpleTarget仍然可以只要你確保你沒有使用位圖,一旦ImageView的清除使用。



查看完整回答
反對 回復 2019-12-12
  • 3 回答
  • 0 關(guān)注
  • 404 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號