Hi! I’m trying to build a row similar to this one(...
# compose
m
Hi! I’m trying to build a row similar to this one(img below): If I use two harcoded strings it works just fine, but in my case, I obtain the first string from the activity intent and the second one from string resources. I don’t get why, when I do so, it breaks the UI. Only the first string is shown, and the rest of the elements of the screen move down a bit. I’m doing it this way because the second string should be clickable and in a different colour. There are probably different ways of doing this, but I can’t see what I am doing wrong here.
Copy code
@Composable
  fun Subtitle(modifier: Modifier = Modifier, first: String, second: String) {
    Row(modifier = modifier.padding(8.dp)) {
      Text(
        text = first,
        color = colorResource(id = R.color.textLight),
        fontSize = 16.sp
      )
      Text(
        modifier = modifier.padding(start = 2.dp),
        text = second,
        color = colorResource(id = R.color.textBrand),
        fontSize = 16.sp
      )
    }
  }
Copy code
Subtitle(first = args.summary, second = stringResource(R.string.general_more_info))
p
I think this would be a good use case for Annotated Strings -> https://developer.android.com/jetpack/compose/text#multiple-styles The clickable part can be implemented like this: https://stackoverflow.com/a/65656351 It’s a bit verbose though to be fair
m
many thanks!! 🙏 will try this way then