zoukankan      html  css  js  c++  java
  • 安卓ProgressBar水平进度条的颜色设置

    安卓系统提供了水平进度条ProgressBar的样式,而我们在实际开发中,差点儿不可能使用默认的样式。原因就是“太丑”^_^

    所以我们在很多其它的时候须要对其颜色进行自己定义,主要使用就是自己定义样式文件。


    再在drawable文件夹下新增progressbar.xml文件,能够设置默认背景色和进度条的颜色

    (值得一提的是支持渐变色)

    代码:

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    
        <item android:id="@android:id/background">
    
            <shape>
    
                <corners android:radius="5dip" />
    
                <gradient
                    android:angle="0"
                    android:centerColor="#ff5a5d5a"
                    android:centerY="0.75"
                    android:endColor="#ff747674"
                    android:startColor="#ff9d9e9d" />
            </shape>
        </item>
    
        <item android:id="@android:id/secondaryProgress">
    
            <clip>
    
                <shape>
    
                    <corners android:radius="5dip" />
    
                    <gradient
                        android:angle="0"
                        android:centerColor="#80ffb600"
                        android:centerY="0.75"
                        android:endColor="#a0ffcb00"
                        android:startColor="#80ffd300" />
                </shape>
            </clip>
        </item>
    
        <item android:id="@android:id/progress">
    
            <clip>
    
                <shape>
    
                    <corners android:radius="5dip" />
    
                    <gradient
                        android:angle="0"
                        android:endColor="#8000ff00"
                        android:startColor="#80ff0000" />
                </shape>
            </clip>
        </item>
    
    </layer-list>

    布局文件定义例如以下:

                
                <ProgressBar
                    android:id="@+id/progressBar"
                    style="?

    android:attr/progressBarStyleHorizontal" android:layout_width="fill_parent" android:layout_height="7.5dp" android:max="100" android:progress="80" android:layout_marginRight="8dp" android:progressDrawable="@drawable/progressbar" android:visibility="visible"/>



  • 相关阅读:
    父div不会被子div撑高
    ie6兼容问题
    浏览器兼容性技巧
    css hack基本语法
    网站设置为灰色
    .net cookie跨域请求指定请求域名
    实体对象属性和值转为键值对Dictionary
    C#通过对象属性名修改值
    jQuery.noConflict()解决imgBox.js依赖jquery版本问题
    华为OJ之最长公共子序列
  • 原文地址:https://www.cnblogs.com/mthoutai/p/7070125.html
Copyright © 2011-2022 走看看