• android 圆形进度条 横向进度条 不确定转圈进度条


    1 横向进度条

    在这里插入图片描述

               <ProgressBar
                                style="@android:style/Widget.ProgressBar.Horizontal"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:max="100"
                                android:secondaryProgress="60"
                                android:progress="55"
                                android:progressDrawable="@drawable/horizontal_progress_drawable_red" />
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    horizontal_progress_drawable_red.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="5px"></corners>
                <solid android:color="@color/redStart"/>
            </shape>
        </item>
    
        <item android:id="@android:id/secondaryProgress">
            <clip>
                <shape>
                    <corners android:radius="2px"></corners>
                    <solid android:color="@color/blueEnd"/>
                </shape>
            </clip>
        </item>
    
        <item android:id="@android:id/progress">
            <clip>
                <shape>
                    <corners android:radius="2px"></corners>
                    <solid android:color="@color/blueEnd"/>
                </shape>
            </clip>
        </item>
    
    </layer-list>
    
    • 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

    在这里插入图片描述

    2 圆形进度条 和第一种是一样的。可以自己控制。

                <ProgressBar
                    android:id="@+id/progress_bar_h"
                    style="?android:attr/progressBarStyleHorizontal"
                    android:layout_width="500px"
                    android:layout_height="500px"
                    android:layout_gravity="center"
                    android:layout_marginTop="28px"
                    android:progressDrawable="@drawable/round_pg_style"
                    android:max="100"
                    android:progress="1"  />
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    round_pg_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
                android:innerRadiusRatio="3.5"
                android:shape="ring"
                android:useLevel="false"
                android:type="sweep"
                android:thicknessRatio="25.0">
                <solid android:color="@color/dian_color"/>
            </shape>
        </item>
        <item android:id="@android:id/progress">
            <rotate
                android:pivotX="50%"
                android:pivotY="50%"
                android:fromDegrees="-90"
                android:toDegrees="-90">
                <shape
                    android:innerRadiusRatio="3.5"
                    android:shape="ring"
                    android:angle="0"
                    android:type="sweep"
                    android:thicknessRatio="25.0">
                    <solid android:color="#44aa00"/>
                </shape>
            </rotate>
        </item>
    </layer-list>
    
    • 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

    在这里插入图片描述

    3 转圈进度条 ,不确定时间

                        <ProgressBar
                            android:id="@+id/progressBar"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_marginTop="50px" />
    
    • 1
    • 2
    • 3
    • 4
    • 5

    4 下载文件,横向进度条 代码

            ProgressDialog   progress = new ProgressDialog(context);
                    progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                    progress.setTitle("");
                    progress.setMessage("下载中");
                    progress.setIndeterminate(false);//设置为fase等待进度更新,设置为true则左右循环滚动
                    progress.setMax(100);
                    progress.setCancelable(false);
                    progress.show();
    
    
    在ui里面更新
    
    progress.setProgress(msg.arg1);
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
  • 相关阅读:
    远程小组软件开发过程(1):流程
    Python用GAN生成对抗性神经网络判别模型拟合多维数组、分类识别手写数字图像可视化...
    高薪聘请“软件测试”专业老师“在线修改测试人简历”、逆风下测试人的简历如何才能脱颖而出
    2021了,真的不要再说 Node.js 是一门编程语言了
    MySQL配置
    MPLS LDP的原理与配置
    神经网络怎么解决过拟合,解决神经网络过拟合
    python 笔记:打开nii格式(nibabel 库)
    软件设计师考前20问,注意啦!!
    Python自动化系统6
  • 原文地址:https://blog.csdn.net/sun6223508/article/details/132914485