rawable/progressbar
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="0"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:startColor="#80ffd300" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="0"
android:endColor="#8000ff00"
android:startColor="#80ff0000" />
</shape>
</clip>
</item> </layer-list>
<ProgressBar
android:id="@+id/ProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="30dp"
android:layout_marginTop="5dp"
android:max="100"
android:progressDrawable="@drawable/progressbar" />
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ChildHolder childHolder = null;
if(convertView == null){
childHolder = new ChildHolder();
convertView = View.inflate(mcontext, R.layout.item_chat, null);
childHolder.ProgressBar = (ProgressBar) convertView.findViewById(R.id.ProgressBar);
convertView.setTag(childHolder);
}else {
childHolder = (ChildHolder) convertView.getTag();
}
// RecordObj 实体对象
RecordObj rd = mlist.get(position); int total_count = 0;
for (int i = 0; i < mlist.size(); i++) {
int count = mlist.get(i).getCount();
total_count += count;
}
DecimalFormat df1 = new DecimalFormat("0.0000");
String str_percent = df1.format((float)rd.getCount() / total_count);
float percent =Float.parseFloat(str_percent) * 100;
DecimalFormat df2 = new DecimalFormat("0.00");
String percents = df2.format(percent) + "%";
int value = childHolder.ProgressBar.getProgress();
if (value == 0) {
doProgress(percent , childHolder.ProgressBar);
} else {
childHolder.ProgressBar.setProgress((int)percent);
}
return convertView;
}