额,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. node设置跨域

    开发过程中在build/dev-server.js配置相关代码以跨域 app.use('/api',proxyMiddleware({ target:'http://m.maizuo.com/v4', ...

  2. Python *Mix_w

    Python的历史起源: 1989年圣诞节期间,由吉多.范罗苏姆创始. Python的优点"优美""明确""简单" python是一门解释型 ...

  3. 关于django的一些基础知识

    1.中间件 中间件的作用 : 在全局范围内控制django的输入和输出的钩子函数 中间件中有5种方法: process_request : 请求进来时,进行验证 process_views : 路由匹 ...

  4. .net 在同步方法中使用拉姆达表达式执行async/await异步操作

    代码如下: static void Main(string[] args) { ((Action)(async () =>{ var data = await HttpHelper.GetOnS ...

  5. web.xml配置说明

    前言 首先,web.xml文件的作用是配置web项目启动时加载的信息.(web.xml并不是一个Web的必要文件,没有web.xml,网站仍然是可以正常工作的.) 而这些配置自然是通过标签来实现的, ...

  6. php源代码安装

    1.在官网下载php安装源文件.版本选择5的最新稳定版. [root@trial download]# wget http://cn.php.net/distributions/php-5.5.38. ...

  7. URL和URI(简单介绍)

    URL与URI 我们经常接触到的就是URL了,它就是我们访问web的一个字符串地址,那么URI是什么呢?他们是什么关系呢? URL:uniform resource location 统一资源定位符U ...

  8. 企业面试题-find结合sed查找替换

    题:把/oldboy目录及其子目录下所有以扩展名.sh结尾的文件中包含oldboy的字符串全部替换成oldgirl 解答: 建立测试数据: [root@tan data]# mkdir /oldboy ...

  9. 在eclipse中启动java程序的时候,每次都会在一个未设置断点的源码里面,卡断点

    可以通过取消这个勾选框,来阻止代码在未设置断点的地方停止 具体位置在:Preferences--Java--Debug

  10. 下载安装ngnix

    在这个网站上进行下载,http://nginx.org/en/download.html,由于我的是windows系统 我下载解压后,打开文件夹里面看到ngix.exe,我去双击它,发现它就是一闪,后 ...