我想让水平进度条变薄我想在进度增加时更改内部进度颜色更改。
<ProgressBar android:id="@+id/progressBar1"
android:layout_width="100dip"
android:layout_marginTop="200dip"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminateOnly="false"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
/>
答案 0 :(得分:2)
This link将帮助您创建可由线程更新的进度条。
您可以使用此样式创建小进度条
<style name="Widget.ProgressBar.Small">
<item name="android:indeterminateDrawable">@android:drawable/progress_small_white</item>
<item name="android:minWidth">16dip</item>
<item name="android:maxWidth">16dip</item>
<item name="android:minHeight">16dip</item>
<item name="android:maxHeight">16dip</item>
</style>
您可以使用以下代码更改颜色。
ProgressBar pg = (ProgressBar)row.findViewById(R.id.progress);
final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
pgDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null,null));
String MyColor = "#FF00FF";
pgDrawable.getPaint().setColor(Color.parseColor(MyColor));
ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
pg.setProgressDrawable(progress);
pg.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));
pg.setProgress(45);
希望这可以帮助!!