# ProgressBarWithText **Repository Path**: catclay/ProgressBarWithText ## Basic Information - **Project Name**: ProgressBarWithText - **Description**: android上的一款带文字的进度条 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2015-05-08 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #ProgressBarWithText android上带文本的ProgressBar 效果演示: ![image](http://git.oschina.net/qibin/ProgressBarWithText/raw/master/image/1.png) ![image](http://git.oschina.net/qibin/ProgressBarWithText/raw/master/image/2.png) 使用方法: 在布局文件配置: \ xmlns:progress="http://schemas.android.com/apk/res/org.loader.progressbarwithtext"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

\ android:id="@+id/progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dip"
progress:textColor="#FFFF0000" />
\

只有一个属性:progress:textColor 指定文本颜色
在Activity中: public class MainActivity extends Activity { private ProgressBarWithText mProgress; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mProgress = (ProgressBarWithText) findViewById(R.id.progress); mProgress.setMax(100); new MyAsyncTask().execute(); } class MyAsyncTask extends AsyncTask { @Override protected Void doInBackground(Void... params) { for(int i=0;i<101;i++) { try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } publishProgress(i); } return null; } @Override protected void onProgressUpdate(Integer... values) { mProgress.setProgress(values[0]); } } }