zoukankan      html  css  js  c++  java
  • Android自定义进度条颜色

    RoteView

    这个没法了只能看源码了,还好下载了源码, sourcesasecore es es 下应有尽有,修改进度条颜色只能找progress ,因为是改变样式,首先找styles.xml

     

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <style name="Widget.ProgressBar">
        <item name="android:indeterminateOnly">true</item>
        <itemname="android:indeterminateDrawable">@android:drawable/progress_medium_white</item>
        <item name="android:indeterminateBehavior">repeat</item>
        <item name="android:indeterminateDuration">3500</item>
        <item name="android:minWidth">48dip</item>
        <item name="android:maxWidth">48dip</item>
        <item name="android:minHeight">48dip</item>
        <item name="android:maxHeight">48dip</item>
    </style>

    进度条颜色,所以找到:

    1
    2
    3
    4
    5
    6
    7
    <style name="Widget.ProgressBar.Horizontal">
        <item name="android:indeterminateOnly">false</item>
        <item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
        <itemname="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
        <item name="android:minHeight">20dip</item>
        <item name="android:maxHeight">20dip</item>
    </style>

    Android:progressDrawable">  所以我们可以找到"drawable下的 progress_horizontal 文件,改变他就可以改变进度条颜色

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    <?xml version="1.0" encoding="utf-8"?>
    <!--
         Copyright (C) 2008 The Android Open Source Project
     
         Licensed under the Apache License, Version 2.0 (the "License");
         you may not use this file except in compliance with the License.
         You may obtain a copy of the License at
     
     
         Unless required by applicable law or agreed to in writing, software
         distributed under the License is distributed on an "AS IS" BASIS,
         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         See the License for the specific language governing permissions and
         limitations under the License.
     
    -->
     
    <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="270"
                    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="270"
                        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="270"
                        android:centerColor="#ffffb600"
                        android:centerY="0.75"
                        android:endColor="#ffffcb00"
                        android:startColor="#ffffd300" />
                </shape>
            </clip>
        </item>
    </layer-list>

     

    1
    2
    3
    android:startColor="#80ffd300"
    android:centerColor="#80ffb600"
    android:endColor="#ff747674"

     

    在我们的项目下新建一个 style.xml 文件

     

    1
    2
    3
    4
    5
    6
    7
    <style name="ProgressBar_Mini" parent="@android:style/Widget.ProgressBar.Horizontal">
        <item name="android:maxHeight">50dip</item>
        <item name="android:minHeight">8dip</item>
        <item name="android:indeterminateOnly">false</item>
        <itemname="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
        <item name="android:progressDrawable">@drawable/progressbar_mini</item>
    </style>

     

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    <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="270"
                    android:centerY="0.75"
                    android:endColor="#F5F5F5"
                    android:startColor="#BEBEBE" />
            </shape>
        </item>
     
        <item android:id="@android:id/secondaryProgress">
            <clip>
                <shape>
                    <corners android:radius="0dip" />
                    <gradient
                        android:angle="270"
                        android:centerY="0.75"
                        android:endColor="#165CBC"
                        android:startColor="#85B0E9" />
                </shape>
            </clip>
        </item>
     
        <item android:id="@android:id/progress">
            <clip>
                <shape>
                    <corners android:radius="5dip" />
                    <gradient
                        android:angle="270"
                        android:centerY="0.75"
                        android:endColor="#165CBC"
                        android:startColor="#85B0E9" />
                </shape>
            </clip>
        </item>
    </layer-list>

    ?

    1
    2
    3
    4
    5
    6
    <ProgressBar
        android:id="@+id/progress"
        style="@style/ProgressBar_Mini"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:progress="50" />

    http://blog.csdn.net/roserose0002/article/details/7988779

  • 相关阅读:
    常用品牌交换机镜像抓包配置
    BGP知识点备忘录
    IS-IS路由协议地址详解
    Linux msmtp+mutt发邮件
    Linux添加一临时用户拥有root权限最快方式
    ELK5.0全程普通用户源码安装指南(CentOS6.5)
    改变文件的拥有者和改变文件的拥有组
    Linux chmod命令详解
    Linux目录介绍
    php时间戳转化成时间相差8小时问题
  • 原文地址:https://www.cnblogs.com/ldq2016/p/5542446.html
Copyright © 2011-2022 走看看