android开发笔记之materialish-progress
materialish-progress介绍
一个material 风格的滚动式进度条(progress wheel)
建议阅读一下参考资料的二篇文章,你就知道这个控件的使用了.
materialish-progress Demo
主是要实现当我们点击一个button时,在后台启动一个线程,从而实时的更新materialish-progress的进度条,进度条从0增加到100.
- 在build.gradle添加库的依赖
dependencies {implementation 'com.pnikosis:materialish-progress:1.7'
}
2.布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"xmlns:material="http://schemas.android.com/apk/res-auto"tools:context=".MainActivity"><com.pnikosis.materialishprogress.ProgressWheelandroid:id="@+id/progress_wheel"android:layout_width="80dp"android:layout_height="80dp"android:layout_gravity="center"material:matProg_barColor="#EF5350"material:matProg_progressIndeterminate="true" /><Buttonandroid:id="@+id/button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="ProgressWhellDemo"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toBottomOf="@id/progress_wheel" /></android.support.constraint.ConstraintLayout>
注意要加入:
xmlns:material="http://schemas.android.com/apk/res-auto"
或者会报错
3.逻辑实现:
import com.pnikosis.materialishprogress.ProgressWheel;public class MainActivity extends AppCompatActivity {private final static String TAG = "ProgressWhellDemo";private ProgressWheel progress_wheel;private Button button;private int progress = 0;private static final int UPDATE_PROGRESS_WHELL = 0;private Handler handler = new Handler() {public void handleMessage(Message msg) {switch (msg.what) {case UPDATE_PROGRESS_WHELL:Log.i(TAG,"handleMessage--progress:"+progress);Log.i(TAG,"handleMessage--(float) (progress/100.0):"+(float) (progress/100.0));progress_wheel.setProgress((float) (progress/100.0));//progress_wheel.setInstantProgress((float) (progress/100.0));break;}super.handleMessage(msg);}};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);init();}private void init() {progress_wheel = (ProgressWheel)findViewById(R.id.progress_wheel);progress_wheel.setBarColor(Color.BLUE);progress_wheel.setVisibility(View.VISIBLE);button = (Button) findViewById(R.id.button);button.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {updateProgress();}});}private void updateProgress() {new Thread(new Runnable() {@Overridepublic void run() {while (progress <= 99){progress++;Log.i(TAG,"sendEmptyMessageDelayed--"+progress);try {Thread.sleep(500);} catch (InterruptedException e) {e.printStackTrace();}handler.sendEmptyMessage(UPDATE_PROGRESS_WHELL);}}}).start();}
}
参考资料
1.github materialish-progress
https://github.com/pnikosis/materialish-progress
2.materialish-progress
https://www.cnblogs.com/oshub/articles/4377497.html
android开发笔记之materialish-progress相关推荐
- 《ArcGIS Runtime SDK for Android开发笔记》——离在线一体化技术:离线矢量数据同步...
1.前言 上一篇文章中我们实现了离线要素的编辑操作,这一篇中主要介绍离在线一体化技术中最后一个环节离线数据的同步功能,通过对数据的上传,服务器端的版本化管理,实现数据生产管理的整个流程. 转载请注明出 ...
- 《ArcGIS Runtime SDK for Android开发笔记》——离在线一体化技术:离线矢量数据下载...
1.前言 1.1.环境准备: ArcGIS for Desktop 10.4.1(10.2.1以上版本即可) ArcGIS for Server 10.4.1 (10.2.1以上版本即可) Postg ...
- Android开发笔记(一百二十六)自定义音乐播放器
MediaRecorder/MediaPlayer 在Android手机上面,音频的处理比视频还要复杂,这真是出人意料.在前面的博文< Android开发笔记(五十七)录像录音与播放>中, ...
- Android开发笔记(一百二十五)自定义视频播放器
视频播放方式 在Android中播放视频的方式有两种: 1.使用MediaPlayer结合SurfaceView进行播放.其中通过SurfaceView显示视频的画面,通过MediaPlayer来设置 ...
- Android开发笔记(九十一)工厂模式
基本概念 工厂模式是一种常用的实例化对象设计模式. 程序开发很多时候都在不停地敲if.else,因为业务需求总在发展变化,今天客户要求生产A产品,明天客户要求把A产品稍微改改变成B产品,当然A产品与B ...
- Android开发笔记(六十四)网页加载与JS调用
内置浏览器 网页视图WebView 如果一个网站已经有现成的网页及业务逻辑,那么使用WebView将其内嵌到app中,省去了app重画页面与http通信的事情,无疑是更经济的做法.WebView就是A ...
- Android开发笔记(六十一)文件下载管理DownloadManager
下载管理DownloadManager 文件下载其实是网络数据访问的一种特殊形式,使用普通的http请求也能完成,就是实现起来会繁琐一些.因为下载功能比较常用,而且业务功能相对统一,所以从Androi ...
- Android开发笔记(五十八)铃声与震动
拖动条SeekBar SeekBar继承自进度条ProcessBar,有关ProcessBar的介绍见<Android开发笔记(四十九)异步任务处理AsyncTask>.SeekBar与P ...
- Android开发笔记(四十九)异步任务处理AsyncTask
AsyncTask异步任务 Thread+Handler方式虽然能够实现多线程的通信处理,但是写起代码来颇为繁琐,所以Android提供了AsyncTask这样一个轻量级的异步任务类,其内部封装好Th ...
- Android开发笔记(一百零八)智能语音
智能语音技术 如今越来越多的app用到了语音播报功能,例如地图导航.天气预报.文字阅读.口语训练等等.语音技术主要分两块,一块是语音转文字,即语音识别:另一块是文字转语音,即语音合成. 对中文来说,和 ...
最新文章
- Centos服务器常用安装指南
- 编程之美-求数组的子数组之和的最大值方法整理
- 7.SpringMVC 配置式开发-ModelAndView和视图解析器
- 1.1 MySQL OCP 实战环境准备
- offline .net3.5
- 华硕主板如何u盘启动电脑
- 【数据采集与数据清洗】课堂笔记
- 中国城市统计年鉴中地级市面板数据(2000-2019年)
- 通过身份证号查出所在籍贯以及性别。
- 市县城镇开发边界内1:500地形图无人机航测实践(M300 RTK+P1+大疆智图+航天远景采集软件)
- 付费应用程序协议下载 苹果_苹果商店 付费app协议填写 apple苹果IOS内购申请教程协议、税务和银行业务配置...
- 冯诺依曼计算机流程图,基本流程图综述
- 即时通信工具中同步离线会话消息的方法及装置
- 【新手案例】Python3.7如何获取网络时间
- 关于树莓派无法解析域名的错误
- 文件名、目录名或卷标语法不正确。
- 【强化学习】用强化学习通关超级马里奥!
- 热水结冰比冷水快?半世纪争议终于解开
- iOS网络NSURLSession使用详解
- 深入浅出C语言:(三)C 语言数组指针(指向数组的指针)