思路:想在ProgressBar上顯示百分比進度,百度、google搜索一下,滿屏都是那個TextProgressBar,我沒引用那個,當(dāng)時覺得應(yīng)該可以更簡單的實現(xiàn),于是直接就在UI上面嘗試,把ProgressBar放在RelativeLayout布局中,并在ProgressBar后面加個TextView,使這兩個控件疊加就解決了,下面是xml,可以參考~
創(chuàng)新互聯(lián)專注于企業(yè)營銷型網(wǎng)站建設(shè)、網(wǎng)站重做改版、臨邑網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5響應(yīng)式網(wǎng)站、商城網(wǎng)站開發(fā)、集團公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為臨邑等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。效果圖:
XML:
<?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="horizontal" android:layout_gravity="center" android:background="#FFFFFF"> <TextView android:id="@+id/tvGraphType" android:layout_width="84dp" android:layout_height="wrap_content" android:padding="2sp" android:gravity="right" android:maxLength="6" android:textColor="#666666" android:text="type" android:textSize="13sp"/> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ProgressBar android:id="@+id/pbGraph" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="right" android:padding="2sp" android:progressDrawable="@drawable/pbarcolor_out" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:layout_marginBottom="4dp"/> <TextView android:id="@+id/tvGraphPercent" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:textColor="#666666" android:text="%" android:textSize="13sp"/> </RelativeLayout> </LinearLayout>
進度條上百分比進度的計算也貼一下吧:
//pbOuts 是ProgressBar,outPercent 是用于顯示百分比的TextView holder.pbOuts.setMax(Graph.getRound(Maxout)); holder.pbOuts.setProgress(Graph.getRound(Outcomes)); if (Maxout>0) { holder.outPercent.setText(String.valueOf(Graph.getRound((Outcomes*100/Maxout)))+"%"); }else { holder.outPercent.setText("0%"); } holder.outPercent.bringToFront();//控件疊加時,顯示在最上面,這句很重要
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
分享文章:Android學(xué)習(xí)—超簡單實現(xiàn)帶進度ProgressBar滾動條-創(chuàng)新互聯(lián)
當(dāng)前地址:http://vcdvsql.cn/article22/ccchjc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、網(wǎng)站營銷、電子商務(wù)、營銷型網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、網(wǎng)站收錄
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容