Android滾動(dòng)條

小小滾動(dòng)條,設(shè)計(jì)還是挺復(fù)雜。

成都創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)公司一直秉承“誠信做人,踏實(shí)做事”的原則,不欺瞞客戶,是我們最起碼的底線! 以服務(wù)為基礎(chǔ),以質(zhì)量求生存,以技術(shù)求發(fā)展,成交一個(gè)客戶多一個(gè)朋友!專注中小微企業(yè)官網(wǎng)定制,網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站設(shè)計(jì),塑造企業(yè)網(wǎng)絡(luò)形象打造互聯(lián)網(wǎng)企業(yè)效應(yīng)。

其中有兩種類型的滾動(dòng)條,一條是普通的滑動(dòng)時(shí)的滾動(dòng)條,一種是快速滾動(dòng)條

項(xiàng)目中曾經(jīng)就出現(xiàn)過XML定義了 android:scrollbars="none" 但是滑動(dòng)時(shí),還是會(huì)出現(xiàn)

滾動(dòng)條,其中是因?yàn)樵O(shè)置了快速滾動(dòng)條的原因 android:fastScrollEnabled="true",而默認(rèn)android:fastScrollEnabled是false的

關(guān)于快速滾動(dòng)條還有最小頁數(shù)設(shè)置,見FashScroller源碼,當(dāng)滾動(dòng)的頁數(shù)在4頁之內(nèi)時(shí),是不會(huì)出現(xiàn)快速滾動(dòng)條的

// Minimum number of pages to justify showing a fast scroll thumb 
 private static int MIN_PAGES = 4;

 以及:

// Are there enough pages to require fast scroll? Recompute only if total count changes 
 if (mItemCount != totalItemCount && visibleItemCount > 0) { 
              mItemCount = totalItemCount; 
              mLongList = mItemCount / visibleItemCount >= MIN_PAGES; 
 }

還有就是有時(shí)可能要自定義滾動(dòng)條的圖片

XML定義如下:

android:scrollbarThumbVertical

android:scrollbarThumbHorizontal

代碼設(shè)置如下:

//修改快速滾動(dòng)條圖片
        try {
                        Field f = AbsListView.class.getDeclaredField("mFastScroller");
                        f.setAccessible(true);
                        Object o = f.get(this);
                        f = f.getType().getDeclaredField("mThumbDrawable");
                        f.setAccessible(true);
                        Drawable drawable = (Drawable) f.get(o);
                        drawable = getResources().getDrawable(R.drawable.icon);
                        f.set(o, drawable);
                } catch (Exception e) {
                        e.printStackTrace();
                }
//修改豎向滾動(dòng)條圖片
                
                try {
                        Field f = View.class.getDeclaredField("mScrollCache");
                        f.setAccessible(true);
                        Object scrollabilityCache  = f.get(this);
                        f = f.getType().getDeclaredField("scrollBar");
                        f.setAccessible(true); 
                        Object scrollBarDrawable = f.get(scrollabilityCache);
                        f = f.getType().getDeclaredField("mVerticalThumb");
                        f.setAccessible(true); 
                        Drawable drawable = (Drawable) f.get(scrollBarDrawable); 
                        drawable = getResources().getDrawable(R.drawable.rating_progress);
                        f.set(scrollBarDrawable, drawable);
                } catch (Exception e) {
                        e.printStackTrace();
                }

新聞標(biāo)題:Android滾動(dòng)條
標(biāo)題網(wǎng)址:http://muchs.cn/article0/isjpio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、營銷型網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、靜態(tài)網(wǎng)站、建站公司做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(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)

搜索引擎優(yōu)化