zoukankan      html  css  js  c++  java
  • 为ProgressBar进度条设置颜色1

    可以通过xml文件来设置,方法如下:

    1:先在布局文件中的ProgressBar加入下面属性:

    android:progressDrawable="@drawable/progress_bar"

    其中progress_bar是你用于设置进度条颜色的xml文件的名字(你当然可以起一个你喜欢的名字)

    2:在res资源文件中的drawable文件中新建上面的xml文件,新建的时候选则根元素为layer-list。如下图:

    3

    image

    3:新建完成后打开该布局文件。

    引入下面代码,设置背景色,该代码引用自:

    http://www.pocketdigi.com/20110706/363.html

    <?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="5.0dip" />
                <gradient android:startColor="#656666" android:endColor="#dbdedf" android:angle="270.0" android:centerY="0.75" android:centerColor="#bbbbbc" />
            </shape>
       
    </item>
    
    <item android:id="@android:id/secondaryProgress">
        
           <clip>
                <shape>
                    <corners android:radius="8.0dip" />
                    <gradient android:startColor="#e71a5e" android:endColor="#6c213a" android:angle="90.0" android:centerY="0.75" android:centerColor="#ac6079" />
                </shape>
            </clip>
    </item>
    
    <item android:id="@android:id/progress">
            <clip>
                <shape>
                    <corners android:radius="8.0dip" />
                    <gradient android:startColor="#464647" android:endColor="#2d9ae7" android:angle="270.0" />
                </shape>
            </clip>
    </item>
    
    
    </layer-list>
    


    作者:KillerLegend
    出处:http://www.cnblogs.com/KillerLegend/
    分享最新的资源,分享个人所得,欢迎关注我的新浪微博
    新浪微博主页:ikey4u
    我的个人博客:www.ikey4u.com
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

     
  • 相关阅读:
    asp.net web api KnownTypeAttribute
    nodejs 递归创建目录
    nodejs 复制、移动文件
    windows cmd命令行下创建文件和文件夹
    nodejs http静态服务器
    C# Socket TCP Server & Client & nodejs client
    gem 安装nokigiri
    nsis 固定到任务栏
    SpringBoot整合JPA
    Freemaker FTL指令常用标签及语法
  • 原文地址:https://www.cnblogs.com/killerlegend/p/3251283.html
Copyright © 2011-2022 走看看