Android Material 常用组件详解(六)—— Progress indicators、Slider 使用详解
1.Progress indicators
Progress indicators是自带动画效果的Progress。进度指示器向用户通知正在进行的进程的状态,例如加载应用程序,提交表单或保存更新。
类型
△ 线性和圆形
Material Design提供两种视觉上不同类型的进度指示器:线性和循环进度指示器。
分别对应LinearProgressIndicator
和CircularProgressIndicator
△ 确定和不确定
进度指标可能是确定的或不确定的。确定指标显示流程需要多长时间。 不确定的指标表示不确定的等待时间。 如果无法检测到进度,或者没有必要指出活动需要多长时间。
只需要添加android:indeterminate="true"
属性就可以循环滚动,实现不确定的进度指示器。
上图分别对应这线性不确定进度指示器、圆形不确定进度指示器、线性确定进度指示器、圆形确定进度指示器
<com.google.android.material.progressindicator.LinearProgressIndicatorandroid:layout_width="match_parent"android:layout_height="wrap_content"android:indeterminate="true"/><com.google.android.material.progressindicator.CircularProgressIndicatorandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:indeterminate="true"/><com.google.android.material.progressindicator.LinearProgressIndicatorandroid:id="@+id/linear_determinate"android:layout_width="match_parent"android:layout_height="wrap_content"/><com.google.android.material.progressindicator.CircularProgressIndicatorandroid:id="@+id/circular_determinate"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"/>
常用属性如下:
属性 | 描述 |
---|---|
app:indicatorDirectionLinear | 线性指示器前进的方向模式 |
app:indicatorDirectionCircular | 圆形指示器前进的方向模式 |
app:indicatorCornerRadius | 指示器和轨道的每个角的圆角半径 |
app:indicatorSize | 进度跟踪和指标的宽度 |
app:circularRadius | 定义圆形进度指示器的半径 |
app:circularInset | 从指示器的外部边缘到指示器边缘的额外空间,相当于margin |
app:trackColor | 进度轨道使用的颜色,进度未完成的颜色 |
app:indicatorColor | 指示器颜色,可设置单一颜色或者颜色数组。 |
设置指示器颜色数组
app:indicatorColor="@array/cat_custom_progress_colors"
colors.xml
<integer-array name="cat_custom_progress_colors"><item>@color/yellow_500</item><item>@color/blue_700</item><item>@color/red_500</item></integer-array>
2.Slider
加强版的SeekBar
Slider
<com.google.android.material.slider.Sliderandroid:id="@+id/slider"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:value="8.09"android:valueFrom="0.0"android:valueTo="11.0" />
RangeSlider
<com.google.android.material.slider.RangeSliderandroid:id="@+id/range_slider"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"app:values="@array/initial_slider_values"android:valueFrom="0.0"android:valueTo="11.0" />
arrays.xml
<resources><array name="initial_slider_values"><item>2.0</item><item>7.0</item></array>
</resources>
修改轨道主题
android:theme="@style/ThemeOverlay.PrimaryPalette.Green"
<style name="ThemeOverlay.PrimaryPalette.Green" parent=""><item name="colorPrimary">#43a047</item><item name="colorPrimaryDark">#00701a</item></style>
添加步长
<com.google.android.material.slider.Sliderandroid:id="@+id/slider_5"android:layout_width="match_parent"android:layout_height="wrap_content"android:theme="@style/ThemeOverlay.PrimaryPalette.Blue"android:valueFrom="0"android:valueTo="5.75"android:stepSize="0.25" />
添加步长并去掉步长间隔
<com.google.android.material.slider.Sliderandroid:id="@+id/slider_6"android:layout_width="match_parent"android:layout_height="wrap_content"android:theme="@style/ThemeOverlay.PrimaryPalette.Green"android:valueFrom="0"android:valueTo="10"android:stepSize="1"app:tickVisible="false"/>
Slider可以实现滑块头部数字变化效果,还可以实现类似刻度尺效果,比原生的SeekBar加强了不少。
常用属性如下:
属性 | 描述 |
---|---|
android:valueFrom | 进度起点 |
android:valueTo | 进度终点 |
android:value | 当前进度点 |
android:stepSize | 步长(必须大于0) |
app:values | 配置多个slider节点 |
app:labelBehavior | slider 滑动时顶部是否显示变化效果 |
app:labelStyle | 配置slider节点顶部view style |
其他属性还有haloColor、haloRadius、thumbColor等,用来配置一些外观
Android Material 常用组件详解(六)—— Progress indicators、Slider 使用详解相关推荐
- android开发常用组件和第三方库(二)
TimLiu-Android 自己总结的Android开源项目及库. github排名 https://github.com/trending, github搜索:https://github.com ...
- 进阶篇-用户界面:4.Android中常用组件
1.下拉菜单 在Web开发中,HTML提供了下拉列表的实现,就是使用<select>元素实现一个下拉列表,在其中每个下拉列表项使用<option>表示即可.这是在Web开发中一 ...
- Android Material Design 系列之 BottomNavigationView + ViewPager + Fragment + BadgeView 开发详解
前言 BottomNavigationView 是 Material Design 提供的一个标准底部导航栏的实现,可以轻松的实现导航栏菜单之间的切换与浏览.底部导航使用户更方便的查看和切换最高层级的 ...
- 详解 Android 的 Activity 组件
本文详细介绍了 Android 应用编程中 Activity 的生命周期.通信方式和 Intent Filter 等内容,并提供了一些日常开发中经常用到的关于 Activity 的技巧和方法.通过本文 ...
- Flume常用组件详解之Source
Flume常用组件详解:Source Flume支持众多的source.sink.拦截器等组件具体实现,详细手册可参考官方文档http://flume.apache.org/FlumeUserGuid ...
- Android 官方架构组件 Navigation 使用详解
前言 前段时间,我在做项目开发的时候对Fragment的管理遇到几个小问题,总觉得在现阶段封装好的Fragment管理器不太优雅.这成为我下决心学习Jetpack在很早之前推出的Navigation库 ...
- Android四大组件之——Activity的生命周期(图文详解)
转载请在文章开头处注明本博客网址:http://www.cnblogs.com/JohnTsai 联系方式:JohnTsai.Work@gmail.com [Andro ...
- android 组件(activity,service,content provider,broadcast receiver,intent)详解
Android应用程序由若干个不同类型的组件组合而成,每一个组件具有其特定的安全保护设计方式,它们的安全直接影响到应用程序的安全.Android应用程序组件的主要类型有:活动(Activity),服务 ...
- 《深入理解 Spring Cloud 与微服务构建》第十六章 Spring Boot Security 详解
<深入理解 Spring Cloud 与微服务构建>第十六章 Spring Boot Security 详解 文章目录 <深入理解 Spring Cloud 与微服务构建>第十 ...
最新文章
- ProtoBuf使用笔记
- IT职场最受欢迎的十大晋升秘决
- VTK:几何对象之Cylinder
- swing 选择对话框_Java Swing –日期选择器对话框
- VO,BO,PO,DO,DTO的区别
- 软件工程课设迭代开发第二天
- 解决libstdc++.so.6: version `GLIBCXX_3.4.22' not found
- python爬虫scrapy连接mongodb_爬虫框架scrapy和数据库MongoDB的结合使用(二)实战
- 使用maven将jar包下载到本地仓库
- 20200114每日一句
- java集合框架图(详细版)
- 数学建模的13种常用的方法
- 计算机硬盘中病毒吗,硬盘中病毒能格式化吗
- 冰尘社补丁php,300英雄冰尘社盒子ios
- 阿里云sms短信服务
- MIT公开课 线性代数(1)
- 当阿里云服务器 ECS 访问不了公网 ip可能存在的原因以及如何解决的办法
- 怎么用计算机搜索文件夹,如何在电脑中查找文件_如何在电脑里查找文件-win7之家...
- appcan图片上传最新实现方式
- 惠普战66prog2拆机_惠普战66二代内部做工怎么样?全新惠普战66二代拆机图解评测(含视频教程)...
热门文章
- matlab ode45例子,matlab的ode45
- 计算机怎么更换硬盘,怎么给台式电脑替换新硬盘?
- 前端工程中常用的文件夹命名(扫盲帖)
- 软件测试课程设计——智云云盘
- ios 出现log不打印 was compiled with optimization - stepping may behave oddly; variables may not be availa
- gcc警告选项汇总 转
- 利用python实现m4a格式到MP3的转换
- Auto CAD2004完全笔记
- 技术风险防控平台:打造金融交易系统的故障免疫能力
- 被吹上天的802.11ac Wave2到底好在哪?还有,Wave1哪去了?