您的位置:首页 > 其它

横向长方形ProgressBar

2016-04-21 14:40 169 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/Forever_Frank/article/details/51208889

android原生的progressbar是带有圆角的,要想实现长方形的progressbar只需要设置下android:progressDrawable属性即可。

<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:progress="40"
android:progressDrawable="@drawable/sty_progress" />

样式的代码如下:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item android:id="@android:id/background">
<shape>
<corners android:radius="0dp" />

<gradient
android:angle="270"
android:centerColor="@color/white"
android:centerY="0"
android:endColor="@color/white"
android:startColor="@color/white" />
</shape>
</item>

<!--
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
-->

<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="0dip" />
<gradient
android:angle="270"
android:centerColor="@color/shallow_red"
android:centerY="0"
android:endColor="@color/shallow_red"
android:startColor="@color/shallow_red" />
</shape>
</clip>
</item>

</layer-list>

注释了的代码表示的是第二条进度,如有需要可以加上。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: