https://kotlinlang.org logo
#compose
Title
# compose
n

Napa Ram

08/17/2021, 8:01 AM
HI Everyone can you please suggest me, how can i achieve the background as per below image, like in starting for 1 dp i want to set black color and then Gray color
d

dbaelz

08/17/2021, 8:39 AM
Out of my mind three ways: • A Row with a Composable left and set the background to Black and then folllowing the other content • A special custom border shape that's only draws on the left • Chaining of background and padding Modifier (see example) -> That sounds like the easiest way to implement and very readable. From performance perspective not sure how great it is when used very often.
Example with background an padding. Because the Modifiers are evaluated from left to right it first draws the black background, then the padding, then the gray background on the padded area.
Copy code
Modifier
        .background(Color.Black)
        .padding(start = 4.dp)
        .background(Color.LightGray)
👍 5
n

Napa Ram

08/17/2021, 1:10 PM
@dbaelz Thanks