這篇文章主要介紹“怎么用Glide框架緩存壓縮圖片做一個網絡圖片查看器”,在日常操作中,相信很多人在怎么用Glide框架緩存壓縮圖片做一個網絡圖片查看器問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么用Glide框架緩存壓縮圖片做一個網絡圖片查看器”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

專注于為中小企業提供網站設計制作、成都網站建設服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業瀘縣免費做網站提供優質的服務。我們立足成都,凝聚了一批互聯網行業人才,有力地推動了1000+企業的穩健成長,幫助中小企業通過網站建設實現規模擴充和轉變。
ImgActivity.java
package com.example.a20200712;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
public class ImgActivity extends AppCompatActivity {
private EditText imgPath;
private ImageView img;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.img_view_layout);
imgPath = findViewById(R.id.img_layout_imgText);
img = findViewById(R.id.img_layout_img);
}
public void imgviewonClick(View view) {
Glide.with(ImgActivity.this).load(imgPath.getText().toString()).into(img);
}}
img_view_layout.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/img_layout_imgText" android:hint="請輸入地址"> </EditText> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="查看" android:onClick="imgviewonClick"></Button> <ImageView android:id="@+id/img_layout_img" android:layout_width="match_parent" android:layout_height="match_parent"></ImageView> </LinearLayout>
到此,關于“怎么用Glide框架緩存壓縮圖片做一個網絡圖片查看器”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注創新互聯網站,小編會繼續努力為大家帶來更多實用的文章!
文章標題:怎么用Glide框架緩存壓縮圖片做一個網絡圖片查看器
網站路徑:http://www.yijiale78.com/article22/pcpgjc.html
成都網站建設公司_創新互聯,為您提供搜索引擎優化、虛擬主機、做網站、品牌網站設計、外貿建站、電子商務
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯