Home > Software engineering >  adding text above icon in jetpack compose
adding text above icon in jetpack compose

Time:12-04

Is there any way how I can show a little description above specific icon in Jetpack Compose like in this picture?

enter image description here

CodePudding user response:

You can use a Box. The children of the Box layout will be stacked over each other.

Box{ 
    Text(text = "Text Above Icon", modifier = text alignment)
    Icon(... , modifier = icon alignment) 
    
}

CodePudding user response:

  /**  Text can be added above an icon in Jetpack Compose by using a combination of the Row and Column composables. The Row composable lays out its children in a single row while the Column composable lays out its children in a single column. To add text above the icon, the Row composable should be used first, followed by the Column composable. This will allow the text to be placed on the top of the icon. For example, the following code will add text above an icon: ***/
    
    Row { 
        Text(text = "Text Above Icon") 
        Column { 
            Icon(... ) 
        } 
    }
  • Related