最近在研究UI,使用到progressBar,默认的是圆形的,我想找到那种长条。里面有个style:@android:Widget.ProgressBar.Horizontal,属性,显示是默认的颜色。不是我想要的颜色。
就重写了下样式
<style name="custom_progressbar_style" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progressbar_custom</item>
自定义的style,需要声明 <pre name="code" class="html" style="font-size: 18px;">parent="android:Widget.ProgressBar.Horizontal",然后修改 android:progressDrawable改成你想要的外观
<pre name="code" class="html"><layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<solid
android:color="@android:color/white"
></solid>
<stroke
android:color="#ff99cc00"
android:width="2dp"
>
</stroke>
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<solid
android:color="#ff99ee00"
></solid>
</shape>
</clip>
</item>
</layer-list>
效果图如下:
<img src="https://img-blog.youkuaiyun.com/20150401210820604" alt="" />