Hello, I'm wondering how I can easily always displ...
# compose
i
Hello, I'm wondering how I can easily always display the icon right after the text, even when there is not enough space, I want to display the icon and break the text into two lines. Any ideas?
Box(
modifier = Modifier .
_width_(80._dp_)
.
_height_(50._dp_)
.
_background_(Color.LightGray)
)
{
Row(
modifier = Modifier.
_fillMaxSize_(),
horizontalArrangement = Arrangement.Start, verticalAlignment = Alignment.CenterVertically )
{
Text(
text = "lorem ipsu", maxLines = 2 ) Icon( Icons.Default.
_AccountBox_,
contentDescription = null, tint = Color.Black, modifier = Modifier .
_padding_(8._dp_)
.
_align_(Alignment.CenterVertically)
.
_size_(24._dp_)
)
}
}
p
try Modifier.weight(1f) to Text, hope it helps
b
Hi, maybe you can use like this:
Copy code
Box(
        modifier = Modifier
            .width(80.dp)
            .height(50.dp)
            .background(Color.LightGray)
    ) {

            Text(
                text = "lorem ipsum",
                maxLines = 2,
                modifier = Modifier.align(Alignment.CenterStart)
            )
            Icon(
                Icons.Default.AccountBox,
                contentDescription = null,
                tint = Color.Black,
                modifier = Modifier
                    .padding(8.dp)
                    .size(24.dp)
                    .align(Alignment.CenterEnd)
            )

    }
}
(I'm not sure it is the best way)