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

Kazemihabib1996

04/02/2020, 4:29 PM
Any Idea why Icon is not vertically centered when I set` fontSize` to Text
Copy code
Surface(color = Color.Green) {
            Row(modifier = Modifier.fillMaxWidth().gravity(RowAlign.Center)) {
                Text("More", style = TextStyle(fontSize = 30.sp, color = Color(0xFFC7C7C7)))
                Icon(Icons.Filled.ArrowForward, tint = Color(0xFFC7C7C7))
            }
        }
m

molikto

04/02/2020, 4:39 PM
the
gravity(RowAlign.Center
is supposed to use on a child of a row. If you have imported
Copy code
androidx.ui.layout.RowScope.gravity
then this is not the correct way
the
RowScope
object should be given by
Copy code
fun Row(
    modifier: Modifier = Modifier.None,
    arrangement: Arrangement.Horizontal = Arrangement.Start,
    children: @Composable() RowScope.() -> Unit
) {
the
children
gives you the
RowScope
object, so you don't need and should not import the
RowScope
yourself
k

Kazemihabib1996

04/02/2020, 4:52 PM
Thank your @molikto actually I'm looking for a way to align all children vertically.
m

molikto

04/02/2020, 4:58 PM
@Kazemihabib1996 If you means a modifier on parent that makes all children align vertically, I also wonder if there is any... but I haven't find one..
👍 1
a

Adam Powell

04/02/2020, 7:51 PM
this is an outstanding TODO at the moment, but it will be a parameter to Row/Column, not a modifier. Modifiers are placed on a child to affect behavior within the parent, not to affect parent behavior of arranging children.
👍 3
Think View properties vs. LayoutParams in Android Views as a comparison
👍 1
4 Views