自定义时间刻度尺,时间选择器,模仿萤石云
生活随笔
收集整理的這篇文章主要介紹了
自定义时间刻度尺,时间选择器,模仿萤石云
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
最近寫了個功能螢石云歷史回放。其中有個時間刻度選擇器,看如下效果
TimeRuler
可以縮放平移的時間刻度尺,方便自定義UI需求。仿螢石云歷史錄像時間軸
效果:
Add it to your build.gradle with:
allprojects {repositories {maven { url "https://jitpack.io" }} }and:
dependencies {implementation 'com.github.Liberations:TimeRuler:{latest version}' }BaseScaleBar支持的屬性設(shè)置(Attributes):
| keyTickHeight | dimension,reference | 關(guān)鍵刻度高度 |
| tickValueOffset | dimension,reference | 刻度文字偏移 |
| cursorPosition | float | 游標相對view width的位置 0~ 1 |
| baselinePosition | float | 刻度尺橫線相對view height的位置 0~1 |
| tickColor | color,reference | 刻度線顏色 |
| showTickLine | boolean | 是否顯示刻度橫線 |
| showCursorLine | boolean | 是否顯示游標線 |
| showTickValue | boolean | 是否顯示刻度值 |
| tickDirectionUp | boolean | 刻度線開口方向 |
| cursorLineColor | color,reference | 游標線顏色 |
| maxScaleValueSize | color,reference | 刻度值最大規(guī)格(字體大小) |
TimeRulerBar支持的額外屬性(Attributes):
| tickValueColor | color,reference | 刻度值顏色 |
| colorScaleBackground | color,reference | 顏色區(qū)域背景色 |
| cursorBackgroundColor | color,reference | 游標背景色 |
| drawCursorContent | boolean | 是否繪制游標內(nèi)容 |
| tickValueSize | dimension,reference | 刻度值文字大小 |
| videoAreaOffset | dimension,reference | 繪制顏色區(qū)域相對于頂部的偏移量 |
| videoAreaHeight | dimension,reference | 繪制顏色區(qū)域的高度 |
| tickValueColor | color,reference | 刻度值顏色 |
基本使用
val calendar = Calendar.getInstance()// 00:00:00 000calendar[Calendar.HOUR_OF_DAY] = 0calendar[Calendar.MINUTE] = 0calendar[Calendar.SECOND] = 0calendar[Calendar.MILLISECOND] = 0var startTime = calendar.timeInMillis// 23:59:59 999calendar[Calendar.HOUR_OF_DAY] = 23calendar[Calendar.MINUTE] = 59calendar[Calendar.SECOND] = 59calendar[Calendar.MILLISECOND] = 999var endTime = calendar.timeInMillis//設(shè)置刻度尺時間范圍timeBar.setRange(startTime, endTime)//設(shè)置初始化縮放模式timeBar.setMode(TimeRulerBar.MODE_UINT_30_MIN)//設(shè)置當前刻度值timeBar.setCursorValue(System.currentTimeMillis())滑動事件監(jiān)聽
timeBar.setOnCursorListener(object : BaseScaleBar.OnCursorListener {override fun onStartTrackingTouch(cursorValue: Long) {//開滑動}override fun onProgressChanged(cursorValue: Long,fromeUser:Boolean) {//刻度發(fā)生變化 fromeUser是否觸摸事件觸發(fā)}override fun onStopTrackingTouch(cursorValue: Long) {//結(jié)束滑動}})更多方法參照Demo
總結(jié)
以上是生活随笔為你收集整理的自定义时间刻度尺,时间选择器,模仿萤石云的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为了加分
- 下一篇: mediawiki搭建使用