最近一直在學(xué)習(xí)從遠(yuǎn)程服務(wù)器獲取圖片,開始時(shí)都是手寫這些處理,后來接觸到了smartImageview這個插件。github獲取地址:https://github.com/loopj/android-smart-p_w_picpath-view
成都創(chuàng)新互聯(lián)公司是一家從事企業(yè)網(wǎng)站建設(shè)、成都做網(wǎng)站、網(wǎng)站建設(shè)、行業(yè)門戶網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)制作的專業(yè)網(wǎng)絡(luò)公司,擁有經(jīng)驗(yàn)豐富的網(wǎng)站建設(shè)工程師和網(wǎng)頁設(shè)計(jì)人員,具備各種規(guī)模與類型網(wǎng)站建設(shè)的實(shí)力,在網(wǎng)站建設(shè)領(lǐng)域樹立了自己獨(dú)特的設(shè)計(jì)風(fēng)格。自公司成立以來曾獨(dú)立設(shè)計(jì)制作的站點(diǎn)上1000+。
官方原版插件說明
Overview
SmartImageView is a drop-in replacement for Android’s standard ImageView which additionally allows p_w_picpaths to be loaded from URLs or the user’s contact address book. Images are cached to memory and to disk for super fast loading.
Features
Drop-in replacement for ImageView
Load p_w_picpaths from a URL
Load p_w_picpaths from the phone’s contact address book
Asynchronous loading of p_w_picpaths, loading happens outside the UI thread
Images are cached to memory and to disk for super fast loading
SmartImage
class is easily extendable to load from other sources
其中用到的就是:setImageUrl()方法,該方法有好幾個重載方法,用到了這個
setImageUrl(String url,int fallbackResource)
這個方法的參數(shù)解析如下:url當(dāng)然是遠(yuǎn)程圖片的地址,第二個參數(shù)是當(dāng)獲取遠(yuǎn)程圖片失敗時(shí),顯示的圖片,是一個int類型的res下的圖片的一個id
在使用時(shí),直接在布局文件里使用SmartImageView就行,這個類繼承自ImageView
<?xml version="1.0"encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.yuanlp.smartp_w_picpathview.loopj.android.p_w_picpath.SmartImageView
android:id="@+id/siv"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
在MainActivity 中
com.yuanlp.smartp_w_picpathviewandroid.support.v7.app.AppCompatActivityandroid.os.Bundlecom.yuanlp.smartp_w_picpathview.loopj.android.p_w_picpath.SmartImageViewMainActivity AppCompatActivity { (Bundle savedInstanceState) { .onCreate(savedInstanceState)setContentView(R.layout.)SmartImageView siv=(SmartImageView) findViewById(R.id.)siv.setImageUrl(R.drawable.)} }
本文標(biāo)題:SmartImageView初接觸
網(wǎng)頁URL:http://aaarwkj.com/article6/ijhhog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、外貿(mào)網(wǎng)站建設(shè)、品牌網(wǎng)站設(shè)計(jì)、建站公司、用戶體驗(yàn)、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)