Chetan Tuteja
07/28/2022, 8:38 AMems
property in Jetpack Compose?Mert TUTSAK
07/28/2022, 8:58 AMletterSpacing
property in TextStyle ?Chetan Tuteja
07/28/2022, 9:03 AMandroid:ems
or setEms(n)
sets the width of a TextView to fit a text of n 'M' letters regardless of the actual text extension and text size.
Letter spacing is not the same I would say.Chrimaeon
07/28/2022, 9:15 AMandroidx.compose.ui.unit.TextUnitKt#getEm(int)
. You can use the same way as dp
-> 24.em
Chetan Tuteja
07/28/2022, 9:17 AMChrimaeon
07/28/2022, 9:18 AMText(
text = ""Text,
fontSize = 24.em
)
Chetan Tuteja
07/28/2022, 9:25 AMems
property allowed be to basically set the ems (or how many characters can be there in one line in a nutshell)
I'm looking to achieve the same via Compose now.Chrimaeon
07/28/2022, 9:28 AM/**
* Sets the width of the TextView to be exactly {@code ems} wide.
*
* This value is used for width calculation if LayoutParams does not force TextView to have an
* exact width. Setting this value overrides previous minimum/maximum configurations such as
* {@link #setMinEms(int)} or {@link #setMaxEms(int)}.
*
* @param ems the exact width of the TextView in terms of ems
*
* @see #setWidth(int)
*
* @attr ref android.R.styleable#TextView_ems
*/
@android.view.RemotableViewMethod
public void *setEms*(int ems)you might be able to “hack” it like this:
Text(
modifier = Modifier.width(Dp(24.em.value)),
text = "Text",
)
Chetan Tuteja
07/28/2022, 9:31 AMChrimaeon
07/28/2022, 9:34 AMval width = with(LocalDensity.current) {
24.em.toDp()
}
Text(
modifier = Modifier.width(width),
text = "",
)
Chetan Tuteja
07/28/2022, 9:38 AM