额,Gif有点卡;

梯形、矩形、圆角、背景色、前景色、进度条中的文字都可以改;

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity"> <choi.ccb.com.trapezoidprogress.progressbar.ProgressButton
android:id="@+id/pb1"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="15dp"
app:progressbtn_radius="1"
app:progressbtn_trapezoid_differ="15dp"
app:progressbtn_enable_trapezoid="true"
app:progressbtn_text_size="14dp"
app:progressbtn_background_color="#43B2BF"
app:progressbtn_background_second_color="#8D99AF" />
<Button
android:id="@+id/bt1"
android:text="梯形变化"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<choi.ccb.com.trapezoidprogress.progressbar.ProgressButton
android:id="@+id/pb2"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="15dp"
app:progressbtn_radius="1"
app:progressbtn_trapezoid_differ="15dp"
app:progressbtn_enable_trapezoid="false"
app:progressbtn_text_size="14dp"
app:progressbtn_background_color="@color/colorAccent"
app:progressbtn_background_second_color="#ccc" />
<choi.ccb.com.trapezoidprogress.progressbar.ProgressButton
android:id="@+id/pb3"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="15dp"
app:progressbtn_radius="0"
app:progressbtn_trapezoid_differ="15dp"
app:progressbtn_enable_trapezoid="false"
app:progressbtn_text_size="14dp"
app:progressbtn_background_color="#43B2BF"
app:progressbtn_background_second_color="#8D99AF" />
<choi.ccb.com.trapezoidprogress.progressbar.ProgressButton
android:id="@+id/pb4"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="15dp"
app:progressbtn_radius="1"
app:progressbtn_trapezoid_differ="15dp"
app:progressbtn_enable_trapezoid="true"
app:progressbtn_text_size="14dp"
app:progressbtn_background_color="#fb2"
app:progressbtn_background_second_color="#999" /> </LinearLayout>
public class MainActivity extends AppCompatActivity {

    private ProgressButton pb1,pb2,pb3,pb4;
private Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pb1 = findViewById(R.id.pb1);
pb2 = findViewById(R.id.pb2);
pb3 = findViewById(R.id.pb3);
pb4 = findViewById(R.id.pb4);
btn = findViewById(R.id.bt1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int num = (int) ((Math.random() * 9 + 1) * 8);
pb1.setTrapezoidDiffer(num);
}
});
} @Override
protected void onResume() {
super.onResume();
simulateProgress();
} private void simulateProgress() {
ValueAnimator animator = ValueAnimator.ofInt(0, 100);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int progress = (int) animation.getAnimatedValue();
pb2.setProgress(progress);
pb3.setProgress(progress);
pb4.setProgress(progress);
}
});
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.setDuration(4000);
animator.start();
}
}

GitHub源码 : https://github.com/CuiChenbo/TrapezoidProgress

Android 梯形进度条、下载进度条;的更多相关文章

  1. Android开发之多线程下载、断点续传、进度条和文本显示

    代码实现了在Android环境下的多线程下载.断点续传.进度条显示和文本显示百分数: import java.io.BufferedReader; import java.io.File; impor ...

  2. Android 高手进阶之自定义View,自定义属性(带进度的圆形进度条)

      Android 高手进阶(21)  版权声明:本文为博主原创文章,未经博主允许不得转载. 转载请注明地址:http://blog.csdn.net/xiaanming/article/detail ...

  3. android 开发-自定义多节点进度条显示

    看效果图: 里面的线段颜色和节点图标都是可以自定义的. main.xml <RelativeLayout xmlns:android="http://schemas.android.c ...

  4. Android中的webview的进度条

    <application android:icon="@drawable/hunqin" android:label="@string/app_name" ...

  5. Android开发 ---基本UI组件4:拖动事件、评分进度条、圆圈式进度条、进度条控制

    Android开发 ---基本UI组件4 1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding=" ...

  6. Android View 之进度条+拖动条+星级评论条....

    PS:将来的你会感谢现在奋斗的自己.... 学习内容: 1.进度条 2.拖动条 3.星级评论条 1.进度条...       进图条这东西想必大家是很熟悉的...为了使用户不会觉得应用程序死掉了,因此 ...

  7. android学习笔记20——ProgressDialog进度条对话框

    ProgressDialog==>进度条对话框 ProgressDialog本身就代表一个进度条对话框,程序只需要创建ProgressDialog实例,并将其显示出来就是一个进度条对话框:开发者 ...

  8. PHP持续保有长连接,利用flush持续更新浏览器UI,下载进度条实现

    如何用PHP+JS实现上传进度条,大部分的人可能都实现过,但是下载呢?如何呢?原理也是差不多的,就是分次读写,每次读多少字节,但是这样的不好就是长连接,一般实现下载进度条常用的两种解决方案是:一种是需 ...

  9. android 14 进度条和拖动条

    进度条: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:l ...

  10. 用 CALayer 定制下载进度条控件

    // // RPProgressView.h // CALayer定制下载进度条控件 // // Created by RinpeChen on 16/1/2. // Copyright © 2016 ...

随机推荐

  1. 生成器yield

    #!/usr/bin/python#coding=utf-8'''Created on 2017年11月23日 from home @author: James zhan ''' def counte ...

  2. encodeURIComponent编码与解码

    问题:JavaScript用encodeURIComponentt编码后无法再后台解码的问题. 目前写法: window.self.location="list.jsp?searchtext ...

  3. LeetCode Rotatelmage

    ---恢复内容开始--- You are given an n x n 2D matrix representing an image. Ratate the image by 90 degrees( ...

  4. docker-compose docker启动工具,容器互联

    简介: docker可以一条命令就运行一个配置好的服务器,很是方便. 但是也有一个问题就是,当参数比较多,映射目录比较多,映射端口比较多………… 我以前就是写个脚本,用脚本来启动,很low啊. 也见到 ...

  5. ﺑﯘﻟﺒﯘﻟﻼﺭ--思恋--IPA--维吾尔语

    很美的维语歌曲, 迪里拜尔将之唱得十分动人心弦.

  6. CodeForces - 589A (STL容器的使用)

    Polycarp has quite recently learned about email aliases. Of course, he used to suspect that the case ...

  7. 使用Java API方式的MapReduce练习

    众所周知,hadoop生态圈的多数组件都是使用java开发的. 那么使用Java API方式实现起来,显得要比其它语言效率更高,更原生态. 前面有一个Hadoop学习笔记02_MapReduce练习 ...

  8. 脱产班第五次大作业-FTP服务器

    下载项目 my_ftp #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import hmac import json import ...

  9. httpd does not appear to be running and proxying cobbler, or SELinux is in the way.

    当我们执行cobbler check时,出现这种错误:httpd does not appear to be running and proxying cobbler, or SELinux is i ...

  10. httpd和tomcat之间的区别和联系?

    difference between Apache HTTP server and Tomcat? In general, the Apache HTTP server is just a plain ...