zoukankan      html  css  js  c++  java
  • 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如何实现,然后自己模仿实现,在于这种学习的方法.

  • 相关阅读:
    前端 JS,localStorage/sessionStorage、cookie 及 url 等实现前台数据共享、传输
    webpack 利用Code Splitting 分批打包、按需下载
    React项目之BrowserRouter路由方式之-------生产环境404问题
    React生产环境打包&&后台环境运行(有跨域+无跨域)
    React前台改用HashRouter并解决两个问题
    React路由基础
    React前台404组件页面+路由控制重定向
    react调用方法
    JavaScript 数组遍历方法的对比
    数据可视化相关库说明
  • 原文地址:https://www.cnblogs.com/lzh-Linux/p/5089190.html
Copyright © 2011-2022 走看看