@@ -30,6 +30,7 @@ class TimeLineContainer(
30
30
private var iconCount: Int? = null
31
31
private var textWidth: Int? = null
32
32
private var routeCount: Int? = null
33
+ private var overlappingWidth: Int? = null
33
34
34
35
private val density = context.resources.displayMetrics.density
35
36
@@ -46,12 +47,13 @@ class TimeLineContainer(
46
47
}
47
48
48
49
iconWidth = convertDpToPixel(9f )
49
- // iconWidth = convertDpToPixel(size) * routes.size
50
50
iconCount = count + 1
51
51
52
52
textWidth = convertDpToPixel(30f )
53
53
routeCount = routes.size
54
54
55
+ overlappingWidth = OVERLAPPING_MARGIN * (routes.size - 1 )
56
+
55
57
doOnLayout {
56
58
routes.forEachIndexed { index, route ->
57
59
val timeLineItem2Binding = TimeLineItem2Binding .inflate(
@@ -60,8 +62,15 @@ class TimeLineContainer(
60
62
false ,
61
63
).apply {
62
64
root.id = View .generateViewId()
65
+ if (index != 0 ) {
66
+ val layoutParams = root.layoutParams as MarginLayoutParams
67
+ layoutParams.marginStart = - OVERLAPPING_MARGIN
68
+ root.requestLayout()
69
+ root.layoutParams = layoutParams
70
+ }
63
71
}
64
72
73
+
65
74
addView(timeLineItem2Binding.root)
66
75
setBindingAttribute(timeLineItem2Binding, route, index)
67
76
}
@@ -151,12 +160,11 @@ class TimeLineContainer(
151
160
val iconCount = iconCount ? : throw IllegalArgumentException (" 로직이 잘못 되었습니다." )
152
161
val textWidth = textWidth ? : throw IllegalArgumentException (" 로직이 잘못 되었습니다." )
153
162
val routeCount = routeCount ? : throw IllegalArgumentException (" 로직이 잘못 되었습니다." )
154
-
163
+ val overlappingWidth = overlappingWidth ? : throw IllegalArgumentException ( " 로직이 잘못 되었습니다. " )
155
164
val extraWidth =
156
- this @TimeLineContainer.width - iconWidth * iconCount - textWidth * routeCount
165
+ this @TimeLineContainer.width - iconWidth * iconCount - textWidth * routeCount + overlappingWidth
157
166
binding.root.layoutParams.width =
158
167
(extraWidth * proportionOfSectionTime).toInt() + iconWidth + textWidth
159
-
160
168
}
161
169
162
170
private fun setIdentityColor (binding : TimeLineItem2Binding , route : TransportRoute ) {
@@ -177,4 +185,8 @@ class TimeLineContainer(
177
185
binding.viewIcon.background = drawable
178
186
binding.viewIcon.background.setTintList(null )
179
187
}
188
+
189
+ companion object {
190
+ private const val OVERLAPPING_MARGIN = 10
191
+ }
180
192
}
0 commit comments