Category

Beginner

Category

Jetpack Compose Simple Stroke Bold Text Label Example

In this post, you’ll learn how to create beautifully outlined text in Jetpack Compose using the `drawStyle` parameter. It’s a simple technique that can make your text stand out!

jetpack compose simple stroke bold text label

This is how the final output will look!

jetpack compose stroke text outline


drawStyle = Stroke(width = 1.5f)

  • In Jetpack Compose, `TextStyle` provides a `drawStyle` property that allows you to apply a stroke effect to text.
  • Increasing the width value makes the outline thicker.

jetpack compose stroke bold text label


 Box {
                            Text(
                                text = "ANDROID",
                                style = TextStyle(
                                    fontSize = 92.sp,
                                    fontWeight = FontWeight.Bold,
                                    color = Color.Blue,
                                    drawStyle = Stroke(width = 8f)
                                )
                            )
                            Text(
                                text = "ANDROID",
                                style = TextStyle(
                                    fontSize = 92.sp,
                                    fontWeight = FontWeight.Bold,
                                    color = Color.White,
                                    drawStyle = Fill
                                )
                            )
                        }

  • We’ll use a Box composable with two Text composables and almost identical properties.
  • The second Text composable is drawn on top, so it appears above the first one on the screen.
  • We’ll apply a stroke to the first `Text` composable, making its blue outline visible around the white text.
  • The second `Text` composable fills the text with white, resulting in white filled text with a blue outline.
  • By default, `Text` uses `Fill` as its `drawStyle`. You can remove `drawStyle = Fill`.

Thats all for today.

RecyclerView With CheckBox In Android Example: 2 Examples And Tutorial About RecyclerView Adapter, Difference Between ListView & RecyclerView, and OnClickListener Will Help You To Know RecyclerView Better.

RecyclerView??? Is that a View? What does it do? How to use this one? are these thoughts running through your head? then Go on. Or you know something about RecyclerView then Refresh your knowledge by reading this post. In this article, you will learn about RecyclerView, RecyclerView Adapter,…