Android WearOs — Kotlin & Jetpack Compose UI : Round Text, Curved Text, Curved Layout | by Fabio Chiarani | Dec, 2023
Unlock the potential of these advanced techniques to elevate your smartwatch app design and functionality to new heights.
If you’re developing an application for WearOs you’ve surely come across the Scaffold
showing the TimeText():
Well, then in that case the guide is made just for you! and is made in Jetpack Compose!
To achieve the effect you see above, thus being able to create your custom curved text at the position of your choice, in Jetpack Compose, you can take advantage of the CurvedLayout
with the curvedText
.
1. As first make sure you have the dependencies in your module:
implementation("androidx.wear.compose:compose-material:1.2.1")
implementation("androidx.wear.compose:compose-foundation:1.2.1")
2. Then, create the composable function that allows you to write the text :
@Composable
private fun MyCoolCurvedText(anchor: Float, color: Color, text: String) {
CurvedLayout(
anchor = anchor,
anchorType = AnchorType.Center,
modifier = Modifier.fillMaxSize(),
) {
curvedRow(
) {
curvedText(
text = text,
style = CurvedTextStyle(
fontSize = 14.sp,
color = color
)
)
}
}
}//required imports:
//import androidx.wear.compose.foundation.AnchorType
//import androidx.wear.compose.foundation.CurvedLayout
//import androidx.wear.compose.foundation.CurvedTextStyle
//import androidx.wear.compose.foundation.curvedRow
//import androidx.wear.compose.material.curvedText
Of course, you can customize it to your liking, and put in more items according to your needs
3. Use it inside your UI
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Box(Modifier.fillMaxSize()) {
MyCoolCurvedText(
anchor = 0f,
color = Color.Red,
text = "Rounded text!"
)
MyCoolCurvedText(
anchor = 90f,
color = Color.Green,
text = "WearOs today!"
)
MyCoolCurvedText(
anchor = 180f,
color = Color.Blue,
text = "I'm rounded!"
)
MyCoolCurvedText(
anchor = 270f,
color = Color.Yellow,
text = "Hello devs!"
)
}
}
}
}
And there you have it!
If you are interested in more WearOs Jetpack Compose Android tips let me know in the comments!
Related Posts
Leave a Reply Cancel reply
Categories
- ! Без рубрики (1)
- ++PU (1)
- 1 (1)
- 1w (1)
- 1win Brazil (1)
- 1win India (1)
- 1WIN Official In Russia (1)
- 1win Turkiye (1)
- 1xbet egypt (1)
- 2ankarafayansustasi.net_may (1)
- ankarafayansustasi.netsiteai apr (1)
- Artificial intelligence (1)
- Arts & Entertainment, Photography (1)
- Banda (7)
- belugasitesi_mAY (1)
- BH_TOPsitesi apr (1)
- BHsitesy_may (2)
- Blog (3)
- Bookkeeping (14)
- Bootcamp de programação (2)
- Bootcamp de programación (2)
- BT_TOPsitesi apr (1)
- casino (5)
- casinom-hub (1)
- casinom-hub.comsitesi apr (3)
- colombian mail order brides (1)
- Cryptocurrency exchange (2)
- Dinamobet_next (1)
- Disease & Illness, Colon Cancer (1)
- Dumanbet (1)
- Dumanbet_next (1)
- Finance, Insurance (1)
- FinTech (5)
- Forex Trading (11)
- Galabet (1)
- Health & Fitness, Fitness Equipment (1)
- Hitbet (1)
- Home & Family, Crafts (1)
- Home & Family, Gardening (1)
- Internet Business, Audio-Video Streaming (1)
- Internet Business, Ecommerce (1)
- Internet Business, Email Marketing (1)
- Internet Business, Internet Marketing (1)
- IT Вакансії (1)
- IT Образование (5)
- IT Освіта (1)
- latin women dating (1)
- mail order bride (1)
- Mars bahis (2)
- Matadorbet (1)
- minimiri.comsitesi apr (3)
- Mobile App Development (771)
- Mostbet Russia (1)
- New Post (1)
- News (14)
- PB_TOPsitesi apr (1)
- PBsitesi_may (1)
- Pusulabet (1)
- redmirepool.bizsitesi apr (2)
- redmirepoolsitesi_may (1)
- Reference & Education, College (1)
- Reference & Education, Sociology (1)
- Rokusitesi apr (1)
- Sober living (6)
- Society, Divorce (1)
- Software development (7)
- Superbetin (1)
- Tempobet_next (1)
- thelongeststride.comsitesi apr (1)
- tipobet-turkiyesitesi apr (1)
- Ultrabet (1)
- Uncategorized (1)
- Игра (2)
- казино (1)
- Криптовалюты (1)
- Новости Криптовалют (1)
- Финтех (7)
- Форекс Брокеры (9)
- Форекс обучение (2)