Rounded progress within Rounded progressbar

            android:id="@+id/progress"
        style="@android:style/Widget.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:indeterminate="false"
        android:progress="100"
        android:progressDrawable="@drawable/progress" />




   
       
           
           
           
       

   

   
                    android:scaleWidth="90%"/>
   



            android:radius="20dp"
        android:topLeftRadius="20dp"
        android:topRightRadius="20dp" />

   


在代码中改变进度条的颜色

一般思路是设置了该xml文件后,直接通过

但是这样设置无效,需要将xml中的各层都取出来,然后改变前景色

LayerDrawable ld = (LayerDrawable) mContext.getResources()
                            .getDrawable(R.drawable.vote_progress_bar_voting);
GradientDrawable gd = (GradientDrawable)ld.
                            findDrawableByLayerId(android.R.id.background);
ScaleDrawable fd = (ScaleDrawable)ld.
                            findDrawableByLayerId(android.R.id.progress);

fd.setColorFilter(redContent, PorterDuff.Mode.SRC_OVER);
progressBar.setProgressDrawable(ld);