




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
【移動應(yīng)用開發(fā)技術(shù)】怎么在Kotlin中實(shí)現(xiàn)一個(gè)StepView方法
本篇文章為大家展示了怎么在Kotlin中實(shí)現(xiàn)一個(gè)StepView方法,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。TimeLineStepView支持時(shí)間軸和StepView,三種布局,支持水平布局,垂直布局和自定義布局
添加依賴implementation
'com.joketng:TimeLineStepView:1.0.1'使用方法在布局文件中添加TimeLineStepView<com.joketng.timelinestepview.view.TimeLineStepView
android:id="@+id/rvVertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:lineWidth="3dp"
app:markSize="10dp"
android:paddingStart="20dp"
app:markStart="@drawable/shape_circle_orange"
app:layoutType="right"
/>在代碼中調(diào)用//OrientationShowType對應(yīng)三種布局方式
//OrientationShowType.TIMELINE(時(shí)間軸方式)
//OrientationShowType.CENTER_VERTICAL(垂直方式)
//OrientationShowType.CENTER_HORIZONTAL(水平方式,支持左右滑動)
rvVertical.initData(listContent,
OrientationShowType.CENTER_VERTICAL,
object
:
TimeLineStepView.OnInitDataCallBack{
override
fun
onBindDataViewHolder(holder:
TimeLineStepAdapter.CustomViewHolder,
position:
Int)
{
}
override
fun
createCustomView(leftLayout:
ViewGroup,
rightLayout:
ViewGroup,
holder:
TimeLineStepAdapter.CustomViewHolder)
{
//LayoutInflater.from(context).inflate(R.layout.item_add_left_view,
leftLayout,
true)
//LayoutInflater.from(context).inflate(R.layout.item_add_right_view,
rightLayout,
true)
}
})
.setLayoutType(type)//設(shè)置布局顯示的樣式左邊:LayoutType.LEFT,右邊:LayoutType.RIGHT,左右:LayoutType.ALL
//設(shè)置stepview進(jìn)度激活的mark圖標(biāo)
.setMarkActive(ContextCompat.getDrawable(context,R.drawable.shape_dot_orange)!!)
//設(shè)置stepview進(jìn)度沒激活的mark圖標(biāo)
.setMarkInActive(ContextCompat.getDrawable(context,R.drawable.shape_dot_gray)!!)
//設(shè)置stepview當(dāng)前進(jìn)度點(diǎn)的mark圖標(biāo)
.setMarkCurrent(ContextCompat.getDrawable(context,R.drawable.shape_current)!!)
//設(shè)置stepview第一個(gè)mark的圖標(biāo)
.setMarkStart(ContextCompat.getDrawable(context,R.drawable.shape_circle_orange)!!)
//設(shè)置stepview最后一個(gè)mark的圖標(biāo)
.setMarkEnd(ContextCompat.getDrawable(context,R.drawable.shape_circle_orange)!!)
//設(shè)置stepview線的寬度
.setLineWidth(context.dipc(2))
//設(shè)置stepview進(jìn)度激活時(shí)線的顏色
.setLineActiveColor(ContextCompat.getColor(context,R.color.c_main_orange))
//設(shè)置stepview進(jìn)度沒有激活時(shí)線的顏色
.setLineInActiveColor(ContextCompat.getColor(context,R.color.c_main_gray))
//設(shè)置是否需要自定義布局(此時(shí)將createCustomView中的注釋打開將自定義布局傳入)
.setIsCustom(true)listContent的取值為mutableListOf(),當(dāng)存在自定義布局的時(shí)候,listContent中添加的實(shí)體需要繼承BaseBean這個(gè)實(shí)體,如果不需要自定義布局,可以直接添加實(shí)體BaseBeanlistContent.add(BaseBean(leftTitle
=
"11-11",
leftTime
=
"08:30",
rightTitle
=
"訂單提交成功",
rightTime
=
"訂單提交成功描述",
timeLineState
=
TimeLineState.ACTIVE))
listContent.add(BaseBean(leftTitle
=
"11-11",
leftTime
=
"08:31",
rightTitle
=
"訂單付款成功",
rightTime
=
"訂單付款成功描述",
timeLineState
=
TimeLineState.ACTIVE))
listContent.add(BaseBean(leftTitle
=
"11-11",
leftTime
=
"10:00",
rightTitle
=
"倉庫已經(jīng)接單",
rightTime
=
"倉庫已經(jīng)接單描述",
timeLineState
=
TimeLineState.ACTIVE))
listContent.add(BaseBean(leftTitle
=
"11-11",
leftTime
=
"10:30",
rightTitle
=
"倉庫處理中",
rightTime
=
"倉庫處理中描述",
timeLineState
=
TimeLineState.ACTIVE))
listContent.add(BaseBean(leftTitle
=
"11-11",
leftTime
=
"11:00",
rightTitle
=
"已出庫",
rightTime
=
"已出庫描述",
timeLineState
=
TimeLineState.ACTIVE))
listContent.add(BaseBean(leftTitle
=
"11-11",
leftTime
=
"11:30",
rightTitle
=
"已發(fā)貨",
rightTime
=
"已發(fā)貨描述",
timeLineState
=
TimeLineState.CURRENT))
listContent.add(BaseBean(leftTitle
=
"11-11",
leftTime
=
"16:00",
rightTitle
=
"已攬件",
rightTime
=
"已攬件描述",
timeLineState
=
TimeLineState.INACTIVE))
listContent.add(BaseBean(leftTitle
=
"11-11",
leftTime
=
"16:30",
rightTitle
=
"運(yùn)輸中",
rightTime
=
"運(yùn)輸中描述",
timeLineState
=
TimeLineState.INACTIVE))BaseBean的五個(gè)參數(shù)前四個(gè)為控件的文本,前四個(gè)參數(shù)不傳的話該控件就不會顯示,最后一個(gè)TimeLineState對應(yīng)進(jìn)度的三種狀態(tài)TimeLineState.ACTIVE,TimeLineState.INACTIVE,TimeLineState.CURRENT,根據(jù)狀態(tài)在onBindDataViewHolder方法中設(shè)置markdrawable,linecolor等,在設(shè)置markSize的時(shí)候,如果大小超過30dp,需要在createCustomView方法或者onBindDataViewHolder方法中調(diào)用holder.llLine.layoutParams.width設(shè)置為大于等于markSize的大小或者設(shè)置為WrapContent,如下holder.llLine.layoutParams.width
=
context.dip(35)
holder.llLine.layoutParams.width
=
LinearLayout.LayoutParams.WRAP_CONTENT對于布局的顯示位置有要求的話可以在createCustomView方法中通過layoutParams來控制val
rightLayoutParams
=
rightLayout.layoutParams
as
LinearLayout.LayoutParams
rightLayoutParams.rightMargin
=
context.dip(30)如果不喜歡在代碼中設(shè)置控件屬性的話可以選擇布局文件中增加屬性<com.joketng.timelinestepview.view.TimeLineStepView
android:id="@+id/rvVertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="20dp"
app:markSize="10dp"
app:markStart="@drawable/shape_circle_orange"
app:markEnd="@drawable/shape_circle_orange"
app:markActive="@drawable/shape_dot_orange"
app:markInActive="@drawable/shape_dot_gray"
app:markCurrent="@drawable/shape_circle_orange"
app:lineWidth="3dp"
app:lineActiveColor="@color/c_main_orange"
app:lineInActiveColor="@color/c_main_gray"
app:isCustom="false"
app:layoutType="right"
/>如果需要可以在onBindDataViewHolder方法中通過holder獲取控件改變控件的樣式,如果想要添加自定義的UI,可以在createCustomView方法中添加自己定義的布局文件,此時(shí)調(diào)用setIsCustom(true)即可rvVertical.initData(listContent,
OrientationShowType.CENTER_VERTICAL,
object
:
TimeLineStepView.OnInitDataCallBack{
override
fun
onBindDataViewHolder(holder:
TimeLineStepAdapter.CustomViewHolder,
position:
Int)
{
holder.tvRightTitle.setTextColor(ContextCompat.getColor(context,
R.color.c_main_black))
holder.tvLeftTitle.setTextColor(ContextCompat.getColor(context,
R.color.c_main_black))
holder.tvRightTime.textSize
=
12f
holder.tvLeftTime.textSize
=
12f
holder.tvRightTime.setTextColor(ContextCompat.getColor(context,
R.color.c_main_gray))
holder.
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 水產(chǎn)養(yǎng)殖基地土地使用權(quán)合同
- 公司技術(shù)服務(wù)采購合同
- 豪華酒店廚師服務(wù)合同
- 電子產(chǎn)品購銷合同標(biāo)準(zhǔn)版
- 房地產(chǎn)投資專項(xiàng)法律服務(wù)合同
- (完整版)農(nóng)村土地租賃合同書
- 光學(xué)玻璃的紫外光固化涂層技術(shù)考核試卷
- 醫(yī)療用品行業(yè)服務(wù)平臺拓展考核試卷
- 搪瓷原材料市場動態(tài)與價(jià)格趨勢考核試卷
- 數(shù)字出版物的長期保存與數(shù)字遺產(chǎn)考核試卷
- GB/T 18913-2002船舶和航海技術(shù)航海氣象圖傳真接收機(jī)
- 高中教師先進(jìn)事跡材料范文六篇
- 烹飪專業(yè)英語課件
- 3d3s基本操作命令教程課件分析
- 人教版三年級語文下冊晨讀課件
- 傳染病防治法培訓(xùn)講義課件
- 河南大學(xué)版(2020)信息技術(shù)六年級下冊全冊教案
- 法律方法階梯實(shí)用版課件
- DB32T 4353-2022 房屋建筑和市政基礎(chǔ)設(shè)施工程檔案資料管理規(guī)程
- 白描課件講義整理
- 實(shí)驗(yàn) 探究彈簧彈力與形變量的關(guān)系2022-2023學(xué)年高一物理(人教版2019必修第一冊)
評論
0/150
提交評論