zoukankan      html  css  js  c++  java
  • Progress 自定义(一)-shape

    需求:自定义ProgressBar,使用系统自定义shape;

    效果图:

    1.默认底色:

    2.第一进度颜色:

    3.第二进度颜色:

    实现分析:

    1.目录结构:

    代码实现:

    1.progress_style.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">
            <shape>
                <corners android:radius="0dip" />
    
                <gradient
                    android:angle="0"
                    android:centerColor="#FFFFF0"
                    android:centerY="0.75"
                    android:endColor="#FFFFF0"
                    android:startColor="#FFFFF0" />
            </shape>
        </item>
        <item android:id="@android:id/secondaryProgress">
            <clip>
                <shape>
                    <corners android:radius="0dip" />
    
                    <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="0dip" />
    
                    <gradient
                        android:angle="0"
                        android:endColor="#ec6810"
                        android:startColor="#ec6810" />
                </shape>
            </clip>
        </item>
    
    </layer-list>

    2.fragment_main.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="20dp"
        tools:context="com.jjc.demo.MainActivity$PlaceholderFragment" >
    
        <ProgressBar
            android:id="@+id/progress"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="30dip"
            android:layout_marginLeft="7dp"
            android:layout_marginRight="7dp"
            android:max="70"
            android:progress="30"
            android:secondaryProgress="50"
            android:progressDrawable="@drawable/progress_style" />
    
    </RelativeLayout>

    代码:http://pan.baidu.com/s/1dD1oyFv

  • 相关阅读:
    进阶之路 | 奇妙的Drawable之旅
    进阶之路 | 奇妙的Animation之旅
    进阶之路 | 奇妙的四大组件之旅
    Laravel
    Laravel 入门
    面试:给我说说你平时是如何优化MySQL的?
    EXPLAIN 查看 SQL 执行计划
    常见的图文布局
    常见的图文布局
    CSS3 的 filter(滤镜) 属性
  • 原文地址:https://www.cnblogs.com/sishuiliuyun/p/3949230.html
Copyright © 2011-2022 走看看