ProgressBar 进度条颜色设置

需求:下载中的颜色要自定义,要替换为另外的一个颜色

方法:就是在

            <ProgressBar
android:layout_weight="1"
android:id="@+id/download_item_progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="15dip"
android:progressDrawable="@drawable/progressbar_style"></ProgressBar>

 在drawable中新建一个progressBar_style.xml文件,

这个属性进行设置,有两个方案:

         第一,设置两张图片:

 <?xml version="1.0" encoding="utf-8"?>  
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">  
       
    <item android:id="@android:id/background"    
          android:drawable="@drawable/progressbar_not" />  
        
    <item android:id="@android:id/secondaryProgress"  
          android:drawable="@drawable/progressbar_not">  
    </item>      
        
    <item android:id="@android:id/progress"  
          android:drawable="@drawable/progressbar_selected">  
           
    </item>    
</layer-list>  

第二种,设置背景颜色:

 <?xml version="1.0" encoding="utf-8"?>  

<item android:id="@android:id/background"
    >  
       <shape>  
           <corners android:radius="5dip" />  
           <gradient  
           android:startColor="#666666"  
           android:centerColor="#666666"  
           android:centerY="0.75"  
           android:endColor="#666666"  
           android:angle="270"  
           />  
       </shape>  
   </item>     
   <item android:id="@android:id/progress"
    >     
       <clip>  
      <shape>  
          <corners android:radius="5dip" />  
          <gradient  
           android:startColor="#da1f3e"  
           android:centerColor="#da1f3e"  
           android:centerY="0.75"  
           android:endColor="#da1f3e"  
           android:angle="270"  
           />  
      </shape>  
       </clip>     
   </item>   
   <item android:id="@android:id/secondaryProgress"
    >     
         <clip>     
             <shape>     
                 <corners android:radius="5dip" />     
                 <gradient     
                         android:startColor="#fed7ec"  
           android:centerColor="#fed7ec"  
           android:centerY="0.75"  
           android:endColor="#fed7ec"  
           android:angle="270"     
                 />     
             </shape>     
         </clip>     
     </item>  
</layer-list>

 其中的属性还要进一步研究具体作用,据文档翻译有设置角度,渐变的。。。



  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值