Android 梯形进度条、下载进度条;

额,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 梯形进度条、下载进度条;的更多相关文章
- Android开发之多线程下载、断点续传、进度条和文本显示
代码实现了在Android环境下的多线程下载.断点续传.进度条显示和文本显示百分数: import java.io.BufferedReader; import java.io.File; impor ...
- Android 高手进阶之自定义View,自定义属性(带进度的圆形进度条)
Android 高手进阶(21) 版权声明:本文为博主原创文章,未经博主允许不得转载. 转载请注明地址:http://blog.csdn.net/xiaanming/article/detail ...
- android 开发-自定义多节点进度条显示
看效果图: 里面的线段颜色和节点图标都是可以自定义的. main.xml <RelativeLayout xmlns:android="http://schemas.android.c ...
- Android中的webview的进度条
<application android:icon="@drawable/hunqin" android:label="@string/app_name" ...
- Android开发 ---基本UI组件4:拖动事件、评分进度条、圆圈式进度条、进度条控制
Android开发 ---基本UI组件4 1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding=" ...
- Android View 之进度条+拖动条+星级评论条....
PS:将来的你会感谢现在奋斗的自己.... 学习内容: 1.进度条 2.拖动条 3.星级评论条 1.进度条... 进图条这东西想必大家是很熟悉的...为了使用户不会觉得应用程序死掉了,因此 ...
- android学习笔记20——ProgressDialog进度条对话框
ProgressDialog==>进度条对话框 ProgressDialog本身就代表一个进度条对话框,程序只需要创建ProgressDialog实例,并将其显示出来就是一个进度条对话框:开发者 ...
- PHP持续保有长连接,利用flush持续更新浏览器UI,下载进度条实现
如何用PHP+JS实现上传进度条,大部分的人可能都实现过,但是下载呢?如何呢?原理也是差不多的,就是分次读写,每次读多少字节,但是这样的不好就是长连接,一般实现下载进度条常用的两种解决方案是:一种是需 ...
- android 14 进度条和拖动条
进度条: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:l ...
- 用 CALayer 定制下载进度条控件
// // RPProgressView.h // CALayer定制下载进度条控件 // // Created by RinpeChen on 16/1/2. // Copyright © 2016 ...
随机推荐
- Java中的值传递与引用传递
1.基本类型和引用类型在内存中的保存 Java中数据类型分为两大类,基本类型和对象类型.相应的,变量也有两种类型:基本类型和引用类型. 基本类型的变量保存原始值,即它代表的值就是数值本身: 而引用类型 ...
- A JSON example
heroes.html<!DOCTYPE html> <html> <head> <meta charset="utf-8"> &l ...
- JavaScript之Math
1. Math Math是js的内置函数,无需创建,把Math作为对象使用就可以调用其属性和方法. 2.Date 2.1 日期对象创建 var now = new Date ( ); 含参数时表 ...
- 初学vue----动画过渡transition简单部分
使用动画效果要用transition包裹,transition(<trsnsition name="xx"><div></div></tr ...
- Mad LIbs小游戏
c1=input('请输入摄氏温度;') c2=float(c1)*9/5+32 print('摄氏温度转换成华氏温度是{}'.format(c2)) name1=input('请输入名字:') na ...
- 缓慢拒绝服务攻击- slowloris.pl
How use Slowloris Requirements: # sudo apt-get update # sudo apt-get install perl # sudo apt-get i ...
- CSS3 实现圆形、椭圆形、三角形等各种形状样式
CSS3 圆形 #css3-circle{ width: 150px; height: 150px; border-radius: 50%; background-color: #232323;} C ...
- 嵌入式Linux内核tasklet机制(附实测代码)
Linux 中断编程分为中断顶半部,中断底半部 中断顶半部: 做紧急,耗时短的事情,同时还启动中断底半部. 中断底半部: 做耗时的事件,这个事件在执行过程可以被中断. 中断底半部实现方法: taskl ...
- Spring/Spring MVC
90.为什么要使用 spring? 答:spring是一个开源框架,是个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架 方便结构简化开发 AOP编码的支持 声明式事物的支持 方便程序的测试 ...
- Day 13 可迭代对象,迭代器对象,for循环迭代,生成器对象,枚举对象
一.迭代器概念:# 器:包含了多个值的容器# 迭代:循环反馈(一次从容器中取出一个值)# 迭代器:从装有多个值的容器中一次取出一个值给外界# ls = 'abcdef'ls = [1, 2, 3, 4 ...