额,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. python url 下载并保存

    方法一:用urllib import jsonimport urllib url_model='{"version":"2","url":& ...

  2. Android 音视频深入 十二 FFmpeg视频替换声音(附源码下载)

    项目地址,求starhttps://github.com/979451341/AudioVideoStudyCodeTwo/tree/master/FFmpeg%E7%BB%99%E8%A7%86%E ...

  3. Android 音视频深入 九 FFmpeg解码视频生成yuv文件(附源码下载)

    项目地址,求star https://github.com/979451341/Audio-and-video-learning-materials/tree/master/FFmpeg(MP4%E8 ...

  4. [Leetcode 134]汽车加油站 Gas Station (环形)

    [题目] There are N gas stations along a circular route, where the amount of gas at station i is gas[i] ...

  5. Python使用MySQL数据库(新)(转)

    http://www.cnblogs.com/fnng/p/3565912.html 一,安装mysql 如果是windows 用户,mysql 的安装非常简单,直接下载安装文件,双击安装文件一步一步 ...

  6. 关于win10安装javaJDK时遇到的问题

    昨天晚上装了一下javaJDK1.8,在安装成功并且按照教程设置完环境变量之后进入了cmd界面,输入java,java -version都正常显示,但是输入javac却报错:javac不是内部或外部命 ...

  7. Asp .Net Core 2.0 登录授权以及多用户登录

    用户登录是一个非常常见的应用场景 .net core 2.0 的登录方式发生了点变化,应该是属于是良性的变化,变得更方便,更容易扩展. 配置 打开项目中的Startup.cs文件,找到Configur ...

  8. python基础--字符串

    字符串 1.形式 单引号括起来的字符串:'hello' 双引号括起来的字符串:"Hello" 三引号括起来的字符串:'''hello'''(三单引号),""&q ...

  9. python用schedule模块实现定时任务

    1 import schedule 2 import time 3 4 def test(): 5 print("I'm working...") 6 def test2(): 7 ...

  10. 【linux基础】cuDNN版本查询

    参考 1. 查看cudnn版本; 完