思路:想在ProgressBar上顯示百分比進度,百度、google搜索一下,滿屏都是那個TextProgressBar,我沒引用那個,當時覺得應該可以更簡單的實現(xiàn),于是直接就在UI上面嘗試,把ProgressBar放在RelativeLayout布局中,并在ProgressBar后面加個TextView,使這兩個控件疊加就解決了,下面是xml,可以參考~
在西林等地區(qū),都構建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都網(wǎng)站制作、網(wǎng)站建設 網(wǎng)站設計制作按需求定制開發(fā),公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,高端網(wǎng)站設計,營銷型網(wǎng)站,外貿網(wǎng)站制作,西林網(wǎng)站建設費用合理。
效果圖:
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ǎng)站名稱:Android學習—超簡單實現(xiàn)帶進度ProgressBar滾動條
鏈接URL:http://jinyejixie.com/article0/gpieio.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供、App設計、網(wǎng)站策劃、網(wǎng)站營銷、靜態(tài)網(wǎng)站、品牌網(wǎng)站設計
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)