我正在尝试根据适配器的位置和状态更改时间轴的颜色。但它不起作用。我正在使用以下条件动态尝试此操作:
private fun setLineColor(holder: TimeLineViewHolder, position: Int, status: OrderStatus) {
when (position) {
0 -> {
when (status) {
OrderStatus.COMPLETED -> holder.timeline.setEndLineColor(R.color.colorAccent, 1)
OrderStatus.INACTIVE -> holder.timeline.setEndLineColor(R.color.grey_color, 1)
OrderStatus.ACTIVE -> holder.timeline.setEndLineColor(R.color.grey_color, 1)
}
}
mFeedList.size - 1 -> {
when (status) {
OrderStatus.COMPLETED -> holder.timeline.setStartLineColor(R.color.colorAccent, 2)
OrderStatus.INACTIVE -> holder.timeline.setStartLineColor(R.color.grey_color, 2)
OrderStatus.ACTIVE -> holder.timeline.setStartLineColor(R.color.grey_color, 2)
}
}
else -> {
when (status) {
OrderStatus.COMPLETED -> {
holder.timeline.setStartLineColor(R.color.colorAccent, 0)
holder.timeline.setEndLineColor(R.color.colorAccent, 0)
}
OrderStatus.INACTIVE -> {
holder.timeline.setStartLineColor(R.color.grey_color, 0)
holder.timeline.setEndLineColor(R.color.grey_color, 0)
}
OrderStatus.ACTIVE -> {
holder.timeline.setStartLineColor(R.color.colorAccent, 0)
holder.timeline.setEndLineColor(R.color.grey_color, 0)
}
}
}
}
}
但颜色仅显示为灰色。也称为#21
我在github上发现了很多这方面的问题,但是它指的是另一个链接,但这也无效。 this is a link
我唯一需要做的就是直到我需要强调颜色的当前位置,然后是禁用的颜色。有没有人有这个解决方案?
检查一下,我认为这可以解决您的问题
dependencies {
compile 'com.github.po10cio:TimeLineView:1.0.2'
}
<me.jerryhanks.stepview.TimeLineView
android:id="@+id/timelineView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp">