【问题标题】:setStartLineColor and setEndLineColor not working for timeline viewsetStartLineColor 和 setEndLineColor 不适用于时间线视图
【发布时间】:2019-04-05 04:27:14
【问题描述】:

我正在尝试根据适配器的位置和状态更改时间线的颜色。但它不工作。我正在使用如下条件动态尝试:

 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

我唯一需要做的就是直到当前位置我需要强调颜色,然后是禁用颜色。有没有人对此有解决方案?

【问题讨论】:

标签: android kotlin timeline


【解决方案1】:

检查这个我认为这可以解决您的问题

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">

https://android-arsenal.com/details/1/6540

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-12
    • 1970-01-01
    • 1970-01-01
    • 2015-03-08
    • 1970-01-01
    • 2021-11-02
    • 1970-01-01
    相关资源
    最近更新 更多