android 多样的进度条progressbar

1,xml布局

<ProgressBar

        android:id="@+id/progressBar"android:layout_width="wrap_content"

        style="?android:attr/progressBarStyle"

        android:layout_height="wrap_content"
       

        android:layout_below="@+id/scrollView"/>

2,style属性:

 默认为?android:attr/progressBarStyle

 style="?android:attr/progressBarStyleHorizontal",水平进度条

 style="?android:attr/progressBarStyleSmall",小号进度条

 style="?android:attr/progressBarStyleLarge",大号进度条

 style="@style/my_circle_progressbar"

3,自定义style属性:

 通过一个旋转一个图片生成一个圆形进度条

style="@style/my_circle_progressbar"

 <style name="my_circle_progressbar">
         <item name="android:indeterminateDrawable">@drawable/my_progressbar_circle</item>
         <item name="android:minWidth">60dp</item>
         <item name="android:minHeight">60dp</item>
         <item name="android:maxWidth">60dp</item>
         <item name="android:maxHeight">60dp</item>
     </style>

 <?xml version="1.0" encoding="utf-8"?>
 <rotate xmlns:android="http://schemas.android.com/apk/res/android"
     android:drawable="@drawable/pic_progress_bar"
     android:fromDegrees="0"
     android:pivotX="50%"
     android:pivotY="50%"
     android:toDegrees="1080">
 </rotate>

自定义水平进度条颜色和样式

 style="@style/progressbar_horizontal"

<style name="progressbar_horizontal">
        <item name="android:indeterminateOnly">false</item>
        <item name="android:progressDrawable">@drawable/layer_progressbar_green_gray</item>
        <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
        <item name="android:minHeight">10dp</item>
        <item name="android:maxHeight">10dp</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:max">100</item>

</style>

@drawable/layer_progressbar_green_gray 如下:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@android:id/background">
        <shape>
            <corners android:radius="@dimen/border_middle"/>
            <solid android:color="#cecece"/>
        </shape>
    </item>
    <item
        android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="@dimen/border_middle"/>
                <solid android:color="@color/light_green"/>
            </shape>
        </clip>
    </item>

</layer-list>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值