• android 自定义Style初探---ProgressBar


    系统自带的ProgressBar太丑了,所以我决定自定义一个Style。

    原来的Style

    <?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="5dp">

    </corners>
    <gradient
    android:startColor="#ff9d9e9d"
    android:centerColor="#ff5a5d5a"
    android:centerY="0.75"
    android:endColor="#ff747674"
    android:angle="270"
    />

    </shape>

    </item>

    <item android:id="@android:id/secondaryProgress">
    <clip
    >
    <shape>
    <corners android:radius="5dp"/>
    <gradient
    android:startColor="#80ffd300"
    android:centerColor="#80ffb600"
    android:centerY="0.75"
    android:endColor="#a0ffcb00"
    android:angle="270"
    />
    </shape>
    </clip>
    </item>

    <item android:id="@android:id/progress">
    <clip>
    <shape>
    <corners android:radius="5dp"></corners>
    <gradient
    android:startColor="#ffffd300"
    android:centerColor="#ffffb600"
    android:centerY="0.75"
    android:endColor="#ffffcb00"
    android:angle="270"
    />
    </shape>
    </clip>

    </item>

    </layer-list>


    自定义之后的:

    progressbarcolor.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/bg_progress"
    >

    </item>
    <item android:id="@android:id/secondaryProgress">
    <clip
    >
    <shape>
    <corners android:radius="5dp"/>
    <gradient
    android:startColor="#80ffd300"
    android:centerColor="#80ffb600"
    android:centerY="0.75"
    android:endColor="#a0ffcb00"
    android:angle="270"
    />
    </shape>
    </clip>
    </item>

    <item android:id="@android:id/progress" android:drawable="@drawable/draw_progress">


    </item>

    </layer-list>


    <style name="my_pb_style" parent="@android:style/Widget.ProgressBar.Horizontal">
            <item name="android:progressDrawable">@drawable/progressbarcolor</item>
        </style>

    其中,还需要两张图片:

    VjmAj2B.png!web.png

    AZBVVzU.png!web.png

    重点在于研究系统的Style如何实现,然后自己模仿实现,在于这种学习的方法.

  • 相关阅读:
    linux下解除端口占用
    设计模式(二)观察者模式
    设计模式(一) 策略模式
    loj #6235. 区间素数个数
    loj #2013. 「SCOI2016」幸运数字
    loj #6014. 「网络流 24 题」最长 k 可重区间集
    loj #6013. 「网络流 24 题」负载平衡
    loj #2255. 「SNOI2017」炸弹
    loj #2051. 「HNOI2016」序列
    loj #6122. 「网络流 24 题」航空路线问题
  • 原文地址:https://www.cnblogs.com/lzh-Linux/p/5089190.html
Copyright © 2020-2023  润新知