Android選擇圖片或拍照圖片上傳到服務(wù)器
最近要搞一個(gè)項(xiàng)目,需要上傳相冊和拍照的圖片,不負(fù)所望,終于完成了! 不過需要說明一下,其實(shí)網(wǎng)上很多教程拍照的圖片,都是縮略圖不是很清晰,所以需要在調(diào)用照相機(jī)的時(shí)候,事先生成一個(gè)地址,用于標(biāo)識拍照的圖片URI
具體上傳代碼:
1.選擇圖片和上傳界面,包括上傳完成和異常的回調(diào)監(jiān)聽
package com.spring.sky.image.upload;
import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.spring.sky.image.upload.network.UploadUtil;
import com.spring.sky.image.upload.network.UploadUtil.OnUploadProcessListener;
/**
* @author spring sky<br>
* Email :vipa1888@163.com<br>
* QQ: 840950105<br>
* 說明:主要用于選擇文件和上傳文件操作
*/
public class MainActivity extends Activity implements OnClickListener,OnUploadProcessListener{
private static final String TAG = "uploadImage";
/**
* 去上傳文件
*/
protected static final int TO_UPLOAD_FILE = 1;
/**
* 上傳文件響應(yīng)
*/
protected static final int UPLOAD_FILE_DONE = 2; //
/**
* 選擇文件
*/
public static final int TO_SELECT_PHOTO = 3;
/**
* 上傳初始化
*/
private static final int UPLOAD_INIT_PROCESS = 4;
/**
* 上傳中
*/
private static final int UPLOAD_IN_PROCESS = 5;
/***
* 這里的這個(gè)URL是我服務(wù)器的javaEE環(huán)境URL
*/
private static String requestURL = "http://192.168.10.160:8080/fileUpload/p/file!upload";
private Button selectButton,uploadButton;
private ImageView imageView;
private TextView uploadImageResult;
private ProgressBar progressBar;
private String picPath = null;
private ProgressDialog progressDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initView();
}
/**
* 初始化數(shù)據(jù)
*/
private void initView() {
selectButton = (Button) this.findViewById(R.id.selectImage);
uploadButton = (Button) this.findViewById(R.id.uploadImage);
selectButton.setOnClickListener(this);
uploadButton.setOnClickListener(this);
imageView = (ImageView) this.findViewById(R.id.imageView);
uploadImageResult = (TextView) findViewById(R.id.uploadImageResult);
progressDialog = new ProgressDialog(this);
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.selectImage:
Intent intent = new Intent(this,SelectPicActivity.class);
startActivityForResult(intent, TO_SELECT_PHOTO);
break;
case R.id.uploadImage:
if(picPath!=null)
{
handler.sendEmptyMessage(TO_UPLOAD_FILE);
}else{
Toast.makeText(this, "上傳的文件路徑出錯", Toast.LENGTH_LONG).show();
}
break;
default:
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode==Activity.RESULT_OK && requestCode == TO_SELECT_PHOTO)
{
picPath = data.getStringExtra(SelectPicActivity.KEY_PHOTO_PATH);
Log.i(TAG, "最終選擇的圖片="+picPath);
Bitmap bm = BitmapFactory.decodeFile(picPath);
imageView.setImageBitmap(bm);
}
super.onActivityResult(requestCode, resultCode, data);
}
/**
* 上傳服務(wù)器響應(yīng)回調(diào)
*/
@Override
public void onUploadDone(int responseCode, String message) {
progressDialog.dismiss();
Message msg = Message.obtain();
msg.what = UPLOAD_FILE_DONE;
msg.arg1 = responseCode;
msg.obj = message;
handler.sendMessage(msg);
}
private void toUploadFile()
{
uploadImageResult.setText("正在上傳中...");
progressDialog.setMessage("正在上傳文件...");
progressDialog.show();
String fileKey = "pic";
UploadUtil uploadUtil = UploadUtil.getInstance();;
uploadUtil.setOnUploadProcessListener(this); //設(shè)置監(jiān)聽器監(jiān)聽上傳狀態(tài)
Map<String, String> params = new HashMap<String, String>();
params.put("orderId", "11111");
uploadUtil.uploadFile( picPath,fileKey, requestURL,params);
}
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case TO_UPLOAD_FILE:
toUploadFile();
break;
case UPLOAD_INIT_PROCESS:
progressBar.setMax(msg.arg1);
break;
case UPLOAD_IN_PROCESS:
progressBar.setProgress(msg.arg1);
break;
case UPLOAD_FILE_DONE:
String result = "響應(yīng)碼:"+msg.arg1+"\n響應(yīng)信息:"+msg.obj+"\n耗時(shí):"+UploadUtil.getRequestTime()+"秒";
uploadImageResult.setText(result);
break;
default:
break;
}
super.handleMessage(msg);
}
};
@Override
public void onUploadProcess(int uploadSize) {
Message msg = Message.obtain();
msg.what = UPLOAD_IN_PROCESS;
msg.arg1 = uploadSize;
handler.sendMessage(msg );
}
@Override
public void initUpload(int fileSize) {
Message msg = Message.obtain();
msg.what = UPLOAD_INIT_PROCESS;
msg.arg1 = fileSize;
handler.sendMessage(msg );
}
}
2.選擇圖片界面,主要涉及兩種方式:選擇圖片和及時(shí)拍照圖片
package com.spring.sky.image.upload;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;
/**
* @author spring sky<br>
* Email :vipa1888@163.com<br>
* QQ: 840950105<br>
* @version 創(chuàng)建時(shí)間:2012-11-22 上午9:20:03
* 說明:主要用于選擇文件操作
*/
public class SelectPicActivity extends Activity implements OnClickListener{
/***
* 使用照相機(jī)拍照獲取圖片
*/
public static final int SELECT_PIC_BY_TACK_PHOTO = 1;
/***
* 使用相冊中的圖片
*/
public static final int SELECT_PIC_BY_PICK_PHOTO = 2;
/***
* 從Intent獲取圖片路徑的KEY
*/
public static final String KEY_PHOTO_PATH = "photo_path";
private static final String TAG = "SelectPicActivity";
private LinearLayout dialogLayout;
private Button takePhotoBtn,pickPhotoBtn,cancelBtn;
/**獲取到的圖片路徑*/
private String picPath;
private Intent lastIntent ;
private Uri photoUri;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.select_pic_layout);
initView();
}
/**
* 初始化加載View
*/
private void initView() {
dialogLayout = (LinearLayout) findViewById(R.id.dialog_layout);
dialogLayout.setOnClickListener(this);
takePhotoBtn = (Button) findViewById(R.id.btn_take_photo);
takePhotoBtn.setOnClickListener(this);
pickPhotoBtn = (Button) findViewById(R.id.btn_pick_photo);
pickPhotoBtn.setOnClickListener(this);
cancelBtn = (Button) findViewById(R.id.btn_cancel);
cancelBtn.setOnClickListener(this);
lastIntent = getIntent();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.dialog_layout:
finish();
break;
case R.id.btn_take_photo:
takePhoto();
break;
case R.id.btn_pick_photo:
pickPhoto();
break;
default:
finish();
break;
}
}
/**
* 拍照獲取圖片
*/
private void takePhoto() {
//執(zhí)行拍照前,應(yīng)該先判斷SD卡是否存在
String SDState = Environment.getExternalStorageState();
if(SDState.equals(Environment.MEDIA_MOUNTED))
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//"android.media.action.IMAGE_CAPTURE"
/***
* 需要說明一下,以下操作使用照相機(jī)拍照,拍照后的圖片會存放在相冊中的
* 這里使用的這種方式有一個(gè)好處就是獲取的圖片是拍照后的原圖
* 如果不實(shí)用ContentValues存放照片路徑的話,拍照后獲取的圖片為縮略圖不清晰
*/
ContentValues values = new ContentValues();
photoUri = this.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, photoUri);
/**-----------------*/
startActivityForResult(intent, SELECT_PIC_BY_TACK_PHOTO);
}else{
Toast.makeText(this,"內(nèi)存卡不存在", Toast.LENGTH_LONG).show();
}
}
/***
* 從相冊中取圖片
*/
private void pickPhoto() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, SELECT_PIC_BY_PICK_PHOTO);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
finish();
return super.onTouchEvent(event);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == Activity.RESULT_OK)
{
doPhoto(requestCode,data);
}
super.onActivityResult(requestCode, resultCode, data);
}
/**
* 選擇圖片后,獲取圖片的路徑
* @param requestCode
* @param data
*/
private void doPhoto(int requestCode,Intent data)
{
if(requestCode == SELECT_PIC_BY_PICK_PHOTO ) //從相冊取圖片,有些手機(jī)有異常情況,請注意
{
if(data == null)
{
Toast.makeText(this, "選擇圖片文件出錯", Toast.LENGTH_LONG).show();
return;
}
photoUri = data.getData();
if(photoUri == null )
{
Toast.makeText(this, "選擇圖片文件出錯", Toast.LENGTH_LONG).show();
return;
}
}
String[] pojo = {MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(photoUri, pojo, null, null,null);
if(cursor != null )
{
int columnIndex = cursor.getColumnIndexOrThrow(pojo[0]);
cursor.moveToFirst();
picPath = cursor.getString(columnIndex);
cursor.close();
}
Log.i(TAG, "imagePath = "+picPath);
if(picPath != null && ( picPath.endsWith(".png") || picPath.endsWith(".PNG") ||picPath.endsWith(".jpg") ||picPath.endsWith(".JPG") ))
{
lastIntent.putExtra(KEY_PHOTO_PATH, picPath);
setResult(Activity.RESULT_OK, lastIntent);
finish();
}else{
Toast.makeText(this, "選擇圖片文件不正確", Toast.LENGTH_LONG).show();
}
}
}
3. 上傳工具類,主要實(shí)現(xiàn)了圖片的上傳,上傳過程的初始化監(jiān)聽和上傳完成的監(jiān)聽,還有上傳耗時(shí)的計(jì)算
package com.spring.sky.image.upload.network;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import android.util.Log;
/**
*
* 上傳工具類
* @author spring sky<br>
* Email :vipa1888@163.com<br>
* QQ: 840950105<br>
* 支持上傳文件和參數(shù)
*/
public class UploadUtil {
private static UploadUtil uploadUtil;
private static final String BOUNDARY = UUID.randomUUID().toString(); // 邊界標(biāo)識 隨機(jī)生成
private static final String PREFIX = "--";
private static final String LINE_END = "\r\n";
private static final String CONTENT_TYPE = "multipart/form-data"; // 內(nèi)容類型
private UploadUtil() {
}
/**
* 單例模式獲取上傳工具類
* @return
*/
public static UploadUtil getInstance() {
if (null == uploadUtil) {
uploadUtil = new UploadUtil();
}
return uploadUtil;
}
private static final String TAG = "UploadUtil";
private int readTimeOut = 10 * 1000; // 讀取超時(shí)
private int connectTimeout = 10 * 1000; // 超時(shí)時(shí)間
/***
* 請求使用多長時(shí)間
*/
private static int requestTime = 0;
private static final String CHARSET = "utf-8"; // 設(shè)置編碼
/***
* 上傳成功
*/
public static final int UPLOAD_SUCCESS_CODE = 1;
/**
* 文件不存在
*/
public static final int UPLOAD_FILE_NOT_EXISTS_CODE = 2;
/**
* 服務(wù)器出錯
*/
public static final int UPLOAD_SERVER_ERROR_CODE = 3;
protected static final int WHAT_TO_UPLOAD = 1;
protected static final int WHAT_UPLOAD_DONE = 2;
/**
* android上傳文件到服務(wù)器
*
* @param filePath
* 需要上傳的文件的路徑
* @param fileKey
* 在網(wǎng)頁上<input type=file name=xxx/> xxx就是這里的fileKey
* @param RequestURL
* 請求的URL
*/
public void uploadFile(String filePath, String fileKey, String RequestURL,
Map<String, String> param) {
if (filePath == null) {
sendMessage(UPLOAD_FILE_NOT_EXISTS_CODE,"文件不存在");
return;
}
try {
File file = new File(filePath);
uploadFile(file, fileKey, RequestURL, param);
} catch (Exception e) {
sendMessage(UPLOAD_FILE_NOT_EXISTS_CODE,"文件不存在");
e.printStackTrace();
return;
}
}
/**
* android上傳文件到服務(wù)器
*
* @param file
* 需要上傳的文件
* @param fileKey
* 在網(wǎng)頁上<input type=file name=xxx/> xxx就是這里的fileKey
* @param RequestURL
* 請求的URL
*/
public void uploadFile(final File file, final String fileKey,
final String RequestURL, final Map<String, String> param) {
if (file == null || (!file.exists())) {
sendMessage(UPLOAD_FILE_NOT_EXISTS_CODE,"文件不存在");
return;
}
Log.i(TAG, "請求的URL=" + RequestURL);
Log.i(TAG, "請求的fileName=" + file.getName());
Log.i(TAG, "請求的fileKey=" + fileKey);
new Thread(new Runnable() { //開啟線程上傳文件
@Override
public void run() {
toUploadFile(file, fileKey, RequestURL, param);
}
}).start();
}
private void toUploadFile(File file, String fileKey, String RequestURL,
Map<String, String> param) {
String result = null;
requestTime= 0;
long requestTime = System.currentTimeMillis();
long responseTime = 0;
try {
URL url = new URL(RequestURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(readTimeOut);
conn.setConnectTimeout(connectTimeout);
conn.setDoInput(true); // 允許輸入流
conn.setDoOutput(true); // 允許輸出流
conn.setUseCaches(false); // 不允許使用緩存
conn.setRequestMethod("POST"); // 請求方式
conn.setRequestProperty("Charset", CHARSET); // 設(shè)置編碼
conn.setRequestProperty("connection", "keep-alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
conn.setRequestProperty("Content-Type", CONTENT_TYPE + ";boundary=" + BOUNDARY);
// conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
/**
* 當(dāng)文件不為空,把文件包裝并且上傳
*/
DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
StringBuffer sb = null;
String params = "";
/***
* 以下是用于上傳參數(shù)
*/
if (param != null && param.size() > 0) {
Iterator<String> it = param.keySet().iterator();
while (it.hasNext()) {
sb = null;
sb = new StringBuffer();
String key = it.next();
String value = param.get(key);
sb.append(PREFIX).append(BOUNDARY).append(LINE_END);
sb.append("Content-Disposition: form-data; name=\"").append(key).append("\"").append(LINE_END).append(LINE_END);
sb.append(value).append(LINE_END);
params = sb.toString();
Log.i(TAG, key+"="+params+"##");
dos.write(params.getBytes());
// dos.flush();
}
}
sb = null;
params = null;
sb = new StringBuffer();
/**
* 這里重點(diǎn)注意: name里面的值為服務(wù)器端需要key 只有這個(gè)key 才可以得到對應(yīng)的文件
* filename是文件的名字,包含后綴名的 比如:abc.png
*/
sb.append(PREFIX).append(BOUNDARY).append(LINE_END);
sb.append("Content-Disposition:form-data; name=\"" + fileKey
+ "\"; filename=\"" + file.getName() + "\"" + LINE_END);
sb.append("Content-Type:image/pjpeg" + LINE_END); // 這里配置的Content-type很重要的 ,用于服務(wù)器端辨別文件的類型的
sb.append(LINE_END);
params = sb.toString();
sb = null;
Log.i(TAG, file.getName()+"=" + params+"##");
dos.write(params.getBytes());
/**上傳文件*/
InputStream is = new FileInputStream(file);
onUploadProcessListener.initUpload((int)file.length());
byte[] bytes = new byte[1024];
int len = 0;
int curLen = 0;
while ((len = is.read(bytes)) != -1) {
curLen += len;
dos.write(bytes, 0, len);
onUploadProcessListener.onUploadProcess(curLen);
}
is.close();
dos.write(LINE_END.getBytes());
byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINE_END).getBytes();
dos.write(end_data);
dos.flush();
//
// dos.write(tempOutputStream.toByteArray());
/**
* 獲取響應(yīng)碼 200=成功 當(dāng)響應(yīng)成功,獲取響應(yīng)的流
*/
int res = conn.getResponseCode();
responseTime = System.currentTimeMillis();
this.requestTime = (int) ((responseTime-requestTime)/1000);
Log.e(TAG, "response code:" + res);
if (res == 200) {
Log.e(TAG, "request success");
InputStream input = conn.getInputStream();
StringBuffer sb1 = new StringBuffer();
int ss;
while ((ss = input.read()) != -1) {
sb1.append((char) ss);
}
result = sb1.toString();
Log.e(TAG, "result : " + result);
sendMessage(UPLOAD_SUCCESS_CODE, "上傳結(jié)果:"
+ result);
return;
} else {
Log.e(TAG, "request error");
sendMessage(UPLOAD_SERVER_ERROR_CODE,"上傳失?。篶ode=" + res);
return;
}
} catch (MalformedURLException e) {
sendMessage(UPLOAD_SERVER_ERROR_CODE,"上傳失?。篹rror=" + e.getMessage());
e.printStackTrace();
return;
} catch (IOException e) {
sendMessage(UPLOAD_SERVER_ERROR_CODE,"上傳失?。篹rror=" + e.getMessage());
e.printStackTrace();
return;
}
}
/**
* 發(fā)送上傳結(jié)果
* @param responseCode
* @param responseMessage
*/
private void sendMessage(int responseCode,String responseMessage)
{
onUploadProcessListener.onUploadDone(responseCode, responseMessage);
}
/**
* 下面是一個(gè)自定義的回調(diào)函數(shù),用到回調(diào)上傳文件是否完成
*
* @author shimingzheng
*
*/
public static interface OnUploadProcessListener {
/**
* 上傳響應(yīng)
* @param responseCode
* @param message
*/
void onUploadDone(int responseCode, String message);
/**
* 上傳中
* @param uploadSize
*/
void onUploadProcess(int uploadSize);
/**
* 準(zhǔn)備上傳
* @param fileSize
*/
void initUpload(int fileSize);
}
private OnUploadProcessListener onUploadProcessListener;
public void setOnUploadProcessListener(
OnUploadProcessListener onUploadProcessListener) {
this.onUploadProcessListener = onUploadProcessListener;
}
public int getReadTimeOut() {
return readTimeOut;
}
public void setReadTimeOut(int readTimeOut) {
this.readTimeOut = readTimeOut;
}
public int getConnectTimeout() {
return connectTimeout;
}
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}
/**
* 獲取上傳使用的時(shí)間
* @return
*/
public static int getRequestTime() {
return requestTime;
}
public static interface uploadProcessListener{
}
}
以上代碼,我就不詳細(xì)講解原理,相關(guān)難點(diǎn)注釋已經(jīng)寫得很清楚了!分享出來,和大家一起學(xué)習(xí)!
相關(guān)服務(wù)器端代碼和客戶端下載:
android客戶端下載
javaEE服務(wù)器端
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android使用post方式上傳圖片到服務(wù)器的方法
- android 上傳文件到服務(wù)器代碼實(shí)例
- Android實(shí)現(xiàn)上傳圖片至java服務(wù)器
- android選擇視頻文件上傳到后臺服務(wù)器
- Android中實(shí)現(xiàn)OkHttp上傳文件到服務(wù)器并帶進(jìn)度
- Android實(shí)現(xiàn)上傳文件到服務(wù)器實(shí)例詳解
- Android使用OKHttp庫實(shí)現(xiàn)視頻文件的上傳到服務(wù)器功能
- android 開發(fā)中使用okhttp上傳文件到服務(wù)器
- Android 通過Base64上傳圖片到服務(wù)器實(shí)現(xiàn)實(shí)例
- android?studio實(shí)現(xiàn)上傳圖片到j(luò)ava服務(wù)器
相關(guān)文章
Android 開發(fā)之Dialog中隱藏鍵盤的正確使用方法
這篇文章主要介紹了Android 開發(fā)之Dialog中隱藏鍵盤的正確使用方法的相關(guān)資料,主要說明Dialog 隱藏鍵盤的注意事項(xiàng),需要的朋友可以參考下2017-09-09
Android開發(fā)之滑動圖片輪播標(biāo)題焦點(diǎn)
這篇文章主要介紹了Android開發(fā)之滑動圖片輪播標(biāo)題焦點(diǎn)的相關(guān)資料,需要的朋友可以參考下2016-05-05
RxJava2.x實(shí)現(xiàn)定時(shí)器的實(shí)例代碼
本篇文章主要介紹了RxJava2.x實(shí)現(xiàn)定時(shí)器,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-06-06
Android開發(fā)之自帶下載器DownloadManager的使用示例代碼
本篇文章主要介紹了Android開發(fā)之自帶下載器DownloadManager的使用示例代碼,Android自帶的DownloadManager是一個(gè)很好的下載文件的工具,有興趣的可以了解一下。2017-03-03
使用Compose制作抖音快手視頻進(jìn)度條Loading動畫效果
這篇文章主要為大家介紹了使用Compose制作抖音快手視頻進(jìn)度條Loading動畫效果,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08
Android項(xiàng)目仿UC瀏覽器和360手機(jī)衛(wèi)士消息常駐欄(通知欄)
本篇文章主要介紹了Android項(xiàng)目仿UC瀏覽器和360手機(jī)衛(wèi)士消息常駐欄(通知欄),可以仿照360的通知欄,有興趣的可以了解一下。2016-11-11
Android 使用Glide加載網(wǎng)絡(luò)圖片等比例縮放的實(shí)現(xiàn)方法
這篇文章主要介紹了Android 使用Glide加載網(wǎng)絡(luò)圖片等比例縮放的實(shí)現(xiàn)方法,需要的朋友可以參考下2018-08-08

