Unable to display emojis properly using Jetpack Compose.
Code
Text(
text = data.emoji.character,
textAlign = TextAlign.Center,
fontSize = 28.sp,
)
![Jetpack Compose text](https://img.codepudding.com/202201/c26d234672aa42c5b9d4e8bd9e086d4c.png)
When using Compose Text
, I am facing compatibility issues.
Tofu and multiple emojis appear as explained here.
![](https://img.codepudding.com/202201/70a912972d464611922dcf5dc00703c1.png)
To fix this, I tried using AppCompatTextView
in AndroidView
.
Code
AndroidView(
factory = { context ->
AppCompatTextView(context).apply {
text = data.emoji.character
textSize = 28F
textAlignment = View.TEXT_ALIGNMENT_CENTER
}
},
)
It displays the emojis without any compatibility issue, but the emojis are faded out.
![](https://img.codepudding.com/202201/8aea48578d2d40dcbc95fb079373474d.png)
CodePudding user response:
I was able to find this issue, which is probably related to your Text
problem.
As to AppCompatTextView
, it has default semi-transparent text color. Setting any color with alpha 1f
solves the problem:
AppCompatTextView(context).apply {
setTextColor(Color.Black.toArgb())
text = "