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 ...
随机推荐
- unity5.x中的关节和布料
关节 布料 关节 铰链关节(Hinge Joint):将两个物体以链条的形式绑在一起,当力量过大超过链条的固定力矩时,两个物体就会产生相互的拉力. 固定关节(Fixed Joint): ...
- python_6
set 集合 {} 无序 s = {1,2,3,4,5} s = {}print(type(s)) # 空{}就是字典 s = {1,2,3,4,5}s = {1,2,3,'22','ss',Fals ...
- css图形——椭圆
在css中,我们也使用border-radius属性来实现椭圆 语法 border-radius:x/y; 说明: x表示圆角的水平半径,y表示圆角的垂直半径. 例如:border-radius:30 ...
- Mosquitto-1.5在Linux上的安装以及Android客户端的实现
一.关于MQTT MQTT(Message Queuing Telemetry Transport,消息队列遥测传输协议),是一种基于发布/订阅(publish/subscribe)模式的" ...
- noj快排
1003.快速排序 时限:1000ms 内存限制:10000K 总时限:3000ms 描述 给定一个数列,用快速排序算法把它排成升序. 输入 第一行是一个整数n(n不大于10000),表示要排序 ...
- gzip 所使用压缩算法的基本原理(选摘)
摘自:http://blog.csdn.net/ghevinn/article/details/45747465 gzip 所使用压缩算法的基本原理 gzip 对于要压缩的文件,首先使用LZ77算法 ...
- HTML <form> action 属性
当提交表单时,发送表单数据到名为 "demo_form.html" 的文件(处理输入): <form action="demo_form.html" me ...
- 05_解决mac百度网盘下载速度慢问题
第一步:下载软件 下载工具包:aria2GUI和chrom插件 链接:https://pan.baidu.com/s/104t6aZXx9zfxBV9rS_eLfg 密码:yg96 ①下载Aria2 ...
- php字符串统计次数的各种方法(转)
<?php $str = 'AbCdEfGaBcDeFgH0234;,!-AaBbCcDdEeFfGg'; $str = strtoupper($str); // 不区分大小写时,全部转换成大写 ...
- WEBBASE篇: 第五篇, CSS知识3
CSS知识3 框模型: 一,外边距(上文) 二, 内边距 1,什么是内边距? 内边距就是内容与元素边缘之间的距离: 注: 内边距会扩大元素边框内所占的区域的 语法: padding: 四个方向的 ...