Java和Android的LRU緩存及實(shí)現(xiàn)原理
一、概述
Android提供了LRUCache類,可以方便的使用它來實(shí)現(xiàn)LRU算法的緩存。Java提供了LinkedHashMap,可以用該類很方便的實(shí)現(xiàn)LRU算法,Java的LRULinkedHashMap就是直接繼承了LinkedHashMap,進(jìn)行了極少的改動(dòng)后就可以實(shí)現(xiàn)LRU算法。
二、Java的LRU算法
Java的LRU算法的基礎(chǔ)是LinkedHashMap,LinkedHashMap繼承了HashMap,并且在HashMap的基礎(chǔ)上進(jìn)行了一定的改動(dòng),以實(shí)現(xiàn)LRU算法。
1、HashMap
首先需要說明的是,HashMap將每一個(gè)節(jié)點(diǎn)信息存儲(chǔ)在Entry<K,V>結(jié)構(gòu)中。Entry<K,V>中存儲(chǔ)了節(jié)點(diǎn)對(duì)應(yīng)的key、value、hash信息,同時(shí)存儲(chǔ)了當(dāng)前節(jié)點(diǎn)的下一個(gè)節(jié)點(diǎn)的引用。因此Entry<K,V>是一個(gè)單向鏈表。HashMap的存儲(chǔ)結(jié)構(gòu)是一個(gè)數(shù)組加單向鏈表的形式。每一個(gè)key對(duì)應(yīng)的hashCode,在HashMap的數(shù)組中都可以找到一個(gè)位置;而如果多個(gè)key對(duì)應(yīng)了相同的hashCode,那么他們?cè)跀?shù)組中對(duì)應(yīng)在相同的位置上,這時(shí),HashMap將把對(duì)應(yīng)的信息放到Entry<K,V>中,并使用鏈表連接這些Entry<K,V>。
static class Entry<K,V> implements Map.Entry<K,V> { final K key; V value; Entry<K,V> next; int hash; /** * Creates new entry. */ Entry(int h, K k, V v, Entry<K,V> n) { value = v; next = n; key = k; hash = h; } public final K getKey() { return key; } public final V getValue() { return value; } public final V setValue(V newValue) { V oldValue = value; value = newValue; return oldValue; } public final boolean equals(Object o) { if (!(o instanceof Map.Entry)) return false; Map.Entry e = (Map.Entry)o; Object k1 = getKey(); Object k2 = e.getKey(); if (k1 == k2 || (k1 != null && k1.equals(k2))) { Object v1 = getValue(); Object v2 = e.getValue(); if (v1 == v2 || (v1 != null && v1.equals(v2))) return true; } return false; } public final int hashCode() { return Objects.hashCode(getKey()) ^ Objects.hashCode(getValue()); } public final String toString() { return getKey() + "=" + getValue(); } /** * This method is invoked whenever the value in an entry is * overwritten by an invocation of put(k,v) for a key k that's already * in the HashMap. */ void recordAccess(HashMap<K,V> m) { } /** * This method is invoked whenever the entry is * removed from the table. */ void recordRemoval(HashMap<K,V> m) { } }
下面貼一下HashMap的put方法的代碼,并進(jìn)行分析
public V put(K key, V value) { if (table == EMPTY_TABLE) { inflateTable(threshold); } if (key == null) return putForNullKey(value); //以上信息不關(guān)心,下面是正常的插入邏輯。 //首先計(jì)算hashCode int hash = hash(key); //通過計(jì)算得到的hashCode,計(jì)算出hashCode在數(shù)組中的位置 int i = indexFor(hash, table.length); //for循環(huán),找到在HashMap中是否存在一個(gè)節(jié)點(diǎn),對(duì)應(yīng)的key與傳入的key完全一致。如果存在,說明用戶想要替換該key對(duì)應(yīng)的value值,因此直接替換value即可返回。 for (Entry<K,V> e = table[i]; e != null; e = e.next) { Object k; if (e.hash == hash && ((k = e.key) == key || key.equals(k))) { V oldValue = e.value; e.value = value; e.recordAccess(this); return oldValue; } } //邏輯執(zhí)行到此處,說明HashMap中不存在完全一致的kye.調(diào)用addEntry,新建一個(gè)節(jié)點(diǎn)保存key、value信息,并增加到HashMap中 modCount++; addEntry(hash, key, value, i); return null; }
在上面的代碼中增加了一些注釋,可以對(duì)整體有一個(gè)了解。下面具體對(duì)一些值得分析的點(diǎn)進(jìn)行說明。
<1> int i = indexFor(hash, table.length);
可以看一下源碼:
static int indexFor(int h, int length) { // assert Integer.bitCount(length) == 1 : "length must be a non-zero power of 2"; return h & (length-1); }
為什么獲得的hashCode(h)要和(length-1)進(jìn)行按位與運(yùn)算?這是為了保證去除掉h的高位信息。如果數(shù)組大小為8(1000),而計(jì)算出的h的值為10(1010),如果直接獲取數(shù)組的index為10的數(shù)據(jù),肯定會(huì)拋出數(shù)組超出界限異常。所以使用按位與(0111&1010),成功清除掉高位信息,得到2(0010),表示對(duì)應(yīng)數(shù)組中index為2的數(shù)據(jù)。效果與取余相同,但是位運(yùn)算的效率明顯更高。
但是這樣有一個(gè)問題,如果length為9,獲取得length-1信息為8(1000),這樣進(jìn)行位運(yùn)算,不但不能清除高位數(shù)據(jù),得到的結(jié)果肯定不對(duì)。所以數(shù)組的大小一定有什么特別的地方。通過查看源碼,可以發(fā)現(xiàn),HashMap無時(shí)無刻不在保證對(duì)應(yīng)的數(shù)組個(gè)數(shù)為2的n次方。
首先在put的時(shí)候,調(diào)用inflateTable方法。重點(diǎn)在于roundUpToPowerOf2方法,雖然它的內(nèi)容包含大量的位相關(guān)的運(yùn)算和處理,沒有看的很明白,但是注釋已經(jīng)明確了,會(huì)保證數(shù)組的個(gè)數(shù)為2的n次方。
private void inflateTable(int toSize) { // Find a power of 2 >= toSize int capacity = roundUpToPowerOf2(toSize); threshold = (int) Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1); table = new Entry[capacity]; initHashSeedAsNeeded(capacity); }
其次,在addEntry等其他位置,也會(huì)使用(2 * table.length)、table.length << 1等方式,保證數(shù)組的個(gè)數(shù)為2的n次方。
<2> for (Entry<K,V> e = table[i]; e != null; e = e.next)
因?yàn)镠ashMap使用的是數(shù)組加鏈表的形式,所以通過hashCode獲取到在數(shù)組中的位置后,得到的不是一個(gè)Entry<K,V>,而是一個(gè)Entry<K,V>的鏈表,一定要循環(huán)鏈表,獲取key對(duì)應(yīng)的value。
<3> addEntry(hash, key, value, i);
先判斷數(shù)組個(gè)數(shù)是否超出閾值,如果超過,需要增加數(shù)組個(gè)數(shù)。然后會(huì)新建一個(gè)Entry,并加到數(shù)組中。
/** * Adds a new entry with the specified key, value and hash code to * the specified bucket. It is the responsibility of this * method to resize the table if appropriate. * * Subclass overrides this to alter the behavior of put method. */ void addEntry(int hash, K key, V value, int bucketIndex) { if ((size >= threshold) && (null != table[bucketIndex])) { resize(2 * table.length); hash = (null != key) ? hash(key) : 0; bucketIndex = indexFor(hash, table.length); } createEntry(hash, key, value, bucketIndex); } /** * Like addEntry except that this version is used when creating entries * as part of Map construction or "pseudo-construction" (cloning, * deserialization). This version needn't worry about resizing the table. * * Subclass overrides this to alter the behavior of HashMap(Map), * clone, and readObject. */ void createEntry(int hash, K key, V value, int bucketIndex) { Entry<K,V> e = table[bucketIndex]; table[bucketIndex] = new Entry<>(hash, key, value, e); size++; }
2、LinkedHashMap
LinkedHashMap在HashMap的基礎(chǔ)上,進(jìn)行了修改。首先將Entry由單向鏈表改成雙向鏈表。增加了before和after兩個(gè)隊(duì)Entry的引用。
private static class Entry<K,V> extends HashMap.Entry<K,V> { // These fields comprise the doubly linked list used for iteration. Entry<K,V> before, after; Entry(int hash, K key, V value, HashMap.Entry<K,V> next) { super(hash, key, value, next); } /** * Removes this entry from the linked list. */ private void remove() { before.after = after; after.before = before; } /** * Inserts this entry before the specified existing entry in the list. */ private void addBefore(Entry<K,V> existingEntry) { after = existingEntry; before = existingEntry.before; before.after = this; after.before = this; } /** * This method is invoked by the superclass whenever the value * of a pre-existing entry is read by Map.get or modified by Map.set. * If the enclosing Map is access-ordered, it moves the entry * to the end of the list; otherwise, it does nothing. */ void recordAccess(HashMap<K,V> m) { LinkedHashMap<K,V> lm = (LinkedHashMap<K,V>)m; if (lm.accessOrder) { lm.modCount++; remove(); addBefore(lm.header); } } void recordRemoval(HashMap<K,V> m) { remove(); } }
同時(shí),LinkedHashMap提供了一個(gè)對(duì)Entry的引用header(private transient Entry<K,V> header)。header的作用就是永遠(yuǎn)只是HashMap中所有成員的頭(header.after)和尾(header.before)。這樣把HashMap本身的數(shù)組加鏈表的格式進(jìn)行了修改。在LinkedHashMap中,即保留了HashMap的數(shù)組加鏈表的數(shù)據(jù)保存格式,同時(shí)增加了一套header作為開始標(biāo)記的雙向鏈表(我們暫且稱之為header的雙向鏈表)。LinkedHashMap就是通過header的雙向鏈表來實(shí)現(xiàn)LRU算法的。header.after永遠(yuǎn)指向最近最不常使用的那個(gè)節(jié)點(diǎn),刪除的話,就是刪除這個(gè)header.after對(duì)應(yīng)的節(jié)點(diǎn)。相對(duì)的,header.before指向的就是剛剛使用過的那個(gè)節(jié)點(diǎn)。
LinkedHashMap并沒有提供put方法,但是LinkedHashMap重寫了addEntry和createEntry方法,如下:
/** * This override alters behavior of superclass put method. It causes newly * allocated entry to get inserted at the end of the linked list and * removes the eldest entry if appropriate. */ void addEntry(int hash, K key, V value, int bucketIndex) { super.addEntry(hash, key, value, bucketIndex); // Remove eldest entry if instructed Entry<K,V> eldest = header.after; if (removeEldestEntry(eldest)) { removeEntryForKey(eldest.key); } } /** * This override differs from addEntry in that it doesn't resize the * table or remove the eldest entry. */ void createEntry(int hash, K key, V value, int bucketIndex) { HashMap.Entry<K,V> old = table[bucketIndex]; Entry<K,V> e = new Entry<>(hash, key, value, old); table[bucketIndex] = e; e.addBefore(header); size++; }
HashMap的put方法,調(diào)用了addEntry方法;HashMap的addEntry方法又調(diào)用了createEntry方法。因此可以把上面的兩個(gè)方法和HashMap中的內(nèi)容放到一起,方便分析,形成如下方法:
void addEntry(int hash, K key, V value, int bucketIndex) { if ((size >= threshold) && (null != table[bucketIndex])) { resize(2 * table.length); hash = (null != key) ? hash(key) : 0; bucketIndex = indexFor(hash, table.length); } HashMap.Entry<K,V> old = table[bucketIndex]; Entry<K,V> e = new Entry<>(hash, key, value, old); table[bucketIndex] = e; e.addBefore(header); size++; // Remove eldest entry if instructed Entry<K,V> eldest = header.after; if (removeEldestEntry(eldest)) { removeEntryForKey(eldest.key); } }
同樣,先判斷是否超出閾值,超出則增加數(shù)組的個(gè)數(shù)。然后創(chuàng)建Entry對(duì)象,并加入到HashMap對(duì)應(yīng)的數(shù)組和鏈表中。與HashMap不同的是LinkedHashMap增加了e.addBefore(header);和removeEntryForKey(eldest.key);這樣兩個(gè)操作。
首先分析一下e.addBefore(header)。其中e是LinkedHashMap.Entry對(duì)象,addBefore代碼如下,作用就是講header與當(dāng)前對(duì)象相關(guān)聯(lián),使當(dāng)前對(duì)象增加到header的雙向鏈表的尾部(header.before):
private void addBefore(Entry<K,V> existingEntry) { after = existingEntry; before = existingEntry.before; before.after = this; after.before = this; }
其次是另一個(gè)重點(diǎn),代碼如下:
// Remove eldest entry if instructed Entry<K,V> eldest = header.after; if (removeEldestEntry(eldest)) { removeEntryForKey(eldest.key); }
其中,removeEldestEntry判斷是否需要?jiǎng)h除最近最不常使用的那個(gè)節(jié)點(diǎn)。LinkedHashMap中的removeEldestEntry(eldest)方法永遠(yuǎn)返回false,如果我們要實(shí)現(xiàn)LRU算法,就需要重寫這個(gè)方法,判斷在什么情況下,刪除最近最不常使用的節(jié)點(diǎn)。removeEntryForKey的作用就是將key對(duì)應(yīng)的節(jié)點(diǎn)在HashMap的數(shù)組加鏈表結(jié)構(gòu)中刪除,源碼如下:
final Entry<K,V> removeEntryForKey(Object key) { if (size == 0) { return null; } int hash = (key == null) ? 0 : hash(key); int i = indexFor(hash, table.length); Entry<K,V> prev = table[i]; Entry<K,V> e = prev; while (e != null) { Entry<K,V> next = e.next; Object k; if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k)))) { modCount++; size--; if (prev == e) table[i] = next; else prev.next = next; e.recordRemoval(this); return e; } prev = e; e = next; } return e; }
removeEntryForKey是HashMap的方法,對(duì)LinkedHashMap中header的雙向鏈表無能為力,而LinkedHashMap又沒有重寫這個(gè)方法,那header的雙向鏈表要如何處理呢。
仔細(xì)看一下代碼,可以看到在成功刪除了HashMap中的節(jié)點(diǎn)后,調(diào)用了e.recordRemoval(this);方法。這個(gè)方法在HashMap中為空,LinkedHashMap的Entry則實(shí)現(xiàn)了這個(gè)方法。其中remove()方法中的兩行代碼為雙向鏈表中刪除當(dāng)前節(jié)點(diǎn)的標(biāo)準(zhǔn)代碼,不解釋。
/** * Removes this entry from the linked list. */ private void remove() { before.after = after; after.before = before; }void recordRemoval(HashMap<K,V> m) { remove(); }
以上,LinkedHashMap增加節(jié)點(diǎn)的代碼分析完畢,可以看到完美的將新增的節(jié)點(diǎn)放在了header雙向鏈表的末尾。
但是,這樣顯然是先進(jìn)先出的算法,而不是最近最不常使用算法。需要在get的時(shí)候,更新header雙向鏈表,把剛剛get的節(jié)點(diǎn)放到header雙向鏈表的末尾。我們來看看get的源碼:
public V get(Object key) { Entry<K,V> e = (Entry<K,V>)getEntry(key); if (e == null) return null; e.recordAccess(this); return e.value; }
代碼很短,第一行的getEntry調(diào)用的是HashMap的getEntry方法,不需要解釋。真正處理header雙向鏈表的代碼是e.recordAccess(this)??匆幌麓a:
/** * Removes this entry from the linked list. */ private void remove() { before.after = after; after.before = before; } /** * Inserts this entry before the specified existing entry in the list. */ private void addBefore(Entry<K,V> existingEntry) { after = existingEntry; before = existingEntry.before; before.after = this; after.before = this; } /** * This method is invoked by the superclass whenever the value * of a pre-existing entry is read by Map.get or modified by Map.set. * If the enclosing Map is access-ordered, it moves the entry * to the end of the list; otherwise, it does nothing. */ void recordAccess(HashMap<K,V> m) { LinkedHashMap<K,V> lm = (LinkedHashMap<K,V>)m; if (lm.accessOrder) { lm.modCount++; remove(); addBefore(lm.header); } }
首先在header雙向鏈表中刪除當(dāng)前節(jié)點(diǎn),再將當(dāng)前節(jié)點(diǎn)添加到header雙向鏈表的末尾。當(dāng)然,在調(diào)用LinkedHashMap的時(shí)候,需要將accessOrder設(shè)置為true,否則就是FIFO算法。
三、Android的LRU算法
Android同樣提供了HashMap和LinkedHashMap,而且總體思路有些類似,但是實(shí)現(xiàn)的細(xì)節(jié)明顯不同。而且Android提供的LruCache雖然使用了LinkedHashMap,但是實(shí)現(xiàn)的思路并不一樣。Java需要重寫removeEldestEntry來判斷是否刪除節(jié)點(diǎn);而Android需要重寫LruCache的sizeOf,返回當(dāng)前節(jié)點(diǎn)的大小,Android會(huì)根據(jù)這個(gè)大小判斷是否超出了限制,進(jìn)行調(diào)用trimToSize方法清除多余的節(jié)點(diǎn)。
Android的sizeOf方法默認(rèn)返回1,默認(rèn)的方式是判斷HashMap中的數(shù)據(jù)個(gè)數(shù)是否超出了設(shè)置的閾值。也可以重寫sizeOf方法,返回當(dāng)前節(jié)點(diǎn)的大小。Android的safeSizeOf會(huì)調(diào)用sizeOf方法,其他判斷閾值的方法會(huì)調(diào)用safeSizeOf方法,進(jìn)行加減操作并判斷閾值。進(jìn)而判斷是否需要清除節(jié)點(diǎn)。
Java的removeEldestEntry方法,也可以達(dá)到同樣的效果。Java需要使用者自己提供整個(gè)判斷的過程,兩者思路還是有些區(qū)別的。
sizeOf,safeSizeOf不需要說明,而put和get方法,雖然和Java的實(shí)現(xiàn)方式不完全一樣,但是思路是相同的,也不需要分析。在LruCache中put方法的最后,會(huì)調(diào)用trimToSize方法,這個(gè)方法用于清除超出的節(jié)點(diǎn)。它的代碼如下:
public void trimToSize(int maxSize) { while (true) { Object key; Object value; synchronized (this) { if ((this.size < 0) || ((this.map.isEmpty()) && (this.size != 0))) { throw new IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!"); } if (size <= maxSize) { break; } Map.Entry toEvict = (Map.Entry)this.map.entrySet().iterator().next(); key = toEvict.getKey(); value = toEvict.getValue(); this.map.remove(key); this.size -= safeSizeOf(key, value); this.evictionCount += 1; } entryRemoved(true, key, value, null); } }
重點(diǎn)需要說明的是Map.Entry toEvict = (Map.Entry)this.map.entrySet().iterator().next();這行代碼。它前面的代碼判斷是否需要?jiǎng)h除最近最不常使用的節(jié)點(diǎn),后面的代碼用于刪除具體的節(jié)點(diǎn)。這行代碼用于獲取最近最不常使用的節(jié)點(diǎn)。
首先需要說明的問題是,Android的LinkedHashMap和Java的LinkedHashMap在思路上一樣,也是使用header保存雙向鏈表。在put和get的時(shí)候,會(huì)更新對(duì)應(yīng)的節(jié)點(diǎn),保存header.after指向最久沒有使用的節(jié)點(diǎn);header.before用于指向剛剛使用過的節(jié)點(diǎn)。所以Map.Entry toEvict = (Map.Entry)this.map.entrySet().iterator().next();這行最終肯定是獲取header.after節(jié)點(diǎn)。下面逐步分析代碼,就可以看到是如何實(shí)現(xiàn)的了。
首先,map.entrySet(),HashMap定義了這個(gè)方法,LinkedHashMap沒有重寫這個(gè)方法。因此調(diào)用的是HashMap對(duì)應(yīng)的方法:
public Set<Entry<K, V>> entrySet() { Set<Entry<K, V>> es = entrySet; return (es != null) ? es : (entrySet = new EntrySet()); }
上面代碼不需要細(xì)說,new一個(gè)EntrySet類的實(shí)例。而EntrySet也是在HashMap中定義,LinkedHashMap中沒有。
private final class EntrySet extends AbstractSet<Entry<K, V>> { public Iterator<Entry<K, V>> iterator() { return newEntryIterator(); } public boolean contains(Object o) { if (!(o instanceof Entry)) return false; Entry<?, ?> e = (Entry<?, ?>) o; return containsMapping(e.getKey(), e.getValue()); } public boolean remove(Object o) { if (!(o instanceof Entry)) return false; Entry<?, ?> e = (Entry<?, ?>)o; return removeMapping(e.getKey(), e.getValue()); } public int size() { return size; } public boolean isEmpty() { return size == 0; } public void clear() { HashMap.this.clear(); } } Iterator<Entry<K, V>> newEntryIterator() { return new EntryIterator(); }
代碼中很明顯的可以看出,Map.Entry toEvict = (Map.Entry)this.map.entrySet().iterator().next(),就是要調(diào)用
newEntryIterator().next(),就是調(diào)用(new EntryIterator()).next()。而EntryIterator類在LinkedHashMap中是有定義的。
private final class EntryIterator extends LinkedHashIterator<Map.Entry<K, V>> { public final Map.Entry<K, V> next() { return nextEntry(); } } private abstract class LinkedHashIterator<T> implements Iterator<T> { LinkedEntry<K, V> next = header.nxt; LinkedEntry<K, V> lastReturned = null; int expectedModCount = modCount; public final boolean hasNext() { return next != header; } final LinkedEntry<K, V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); LinkedEntry<K, V> e = next; if (e == header) throw new NoSuchElementException(); next = e.nxt; return lastReturned = e; } public final void remove() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (lastReturned == null) throw new IllegalStateException(); LinkedHashMap.this.remove(lastReturned.key); lastReturned = null; expectedModCount = modCount; } }
現(xiàn)在可以得到結(jié)論,trimToSize中的那行代碼得到的就是header.next對(duì)應(yīng)的節(jié)點(diǎn),也就是最近最不常使用的那個(gè)節(jié)點(diǎn)。
以上就是對(duì)Android Java LRU緩存的實(shí)現(xiàn)原理做的詳解,后續(xù)繼續(xù)補(bǔ)充相關(guān)資料,謝謝大家對(duì)本站的支持!
相關(guān)文章
Android Studio如何快速導(dǎo)入jar和.so文件
這篇文章主要介紹了Android Studio如何快速導(dǎo)入jar和.so文件的相關(guān)知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-12-12Android應(yīng)用中使用ListView來分頁顯示刷新的內(nèi)容
這篇文章主要介紹了Android應(yīng)用中使用ListView來分頁顯示刷新的內(nèi)容的方法,展示了一個(gè)點(diǎn)擊按鈕進(jìn)行刷新的實(shí)例以及下拉刷新分頁顯示的要點(diǎn)解析,需要的朋友可以參考下2016-04-04Android 簡單的圖片查看器源碼實(shí)現(xiàn)
本篇文章主要介紹了Android 簡單的圖片查看器源碼實(shí)現(xiàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09Android用tabhost實(shí)現(xiàn) 界面切換,每個(gè)界面為一個(gè)獨(dú)立的activity操作
這篇文章主要介紹了Android用tabhost實(shí)現(xiàn) 界面切換,每個(gè)界面為一個(gè)獨(dú)立的activity操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-09-09Android Studio實(shí)現(xiàn)長方體表面積計(jì)算器
這篇文章主要為大家詳細(xì)介紹了Android Studio實(shí)現(xiàn)長方體表面積計(jì)算器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-05-05Android編程動(dòng)態(tài)按鈕實(shí)現(xiàn)方法
這篇文章主要介紹了Android編程動(dòng)態(tài)按鈕實(shí)現(xiàn)方法,分享了onTouch方法及xml調(diào)用兩種實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-10-10Android開發(fā)實(shí)戰(zhàn)之漂亮的ViewPager引導(dǎo)頁
這篇文章主要介紹了Android開發(fā)實(shí)戰(zhàn)中漂亮ViewPager引導(dǎo)頁的制作過程,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-08-08