Текст виджета Android Glance не обрезается должным образом внутри строкиAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Текст виджета Android Glance не обрезается должным образом внутри строки

Сообщение Anonymous »

Я использую платформу Jetpack Gloss для создания виджетов в Android и столкнулся с проблемой при использовании текста внутри строки.
Ожидаемое поведение:- > Текст должен обрезаться, как только он касается другого элемента внутри строки.
Фактическое поведение:- Текст сначала выталкивает другие элементы из представления, а затем усекается.
Вот скриншот проблемы
Это нормально
[img]https:/ /i.sstatic.net/trJocgzy.png[/img]

Это не так
Изображение

Box(modifier = GlanceModifier.background(ColorProvider(day = backgroundColor, night = backgroundColorDark))
.padding(
horizontal = 14.dp,
vertical = 14.dp).clickable(onClick = actionStartActivity(context, Uri.parse(widgetUri)))) {
Column(
modifier = GlanceModifier.fillMaxSize(),
verticalAlignment = Alignment.Vertical.Top,
horizontalAlignment = Alignment.Horizontal.Start,
) {
Row(
modifier = GlanceModifier.fillMaxWidth(),
horizontalAlignment = Alignment.Horizontal.CenterHorizontally,
verticalAlignment = Alignment.Vertical.CenterVertically
) {

Row(
verticalAlignment = Alignment.Vertical.CenterVertically)
{
Box (
modifier = GlanceModifier.clickable(onClick = actionRunCallback(
parameters = actionParametersOf(habitIdKey to habitId)
))
) {
Image(
provider = ImageProvider(R.drawable.check_24), contentDescription = null,
colorFilter = ColorFilter.tint(

if (isTodayCompleted)
ColorProvider(day = Color.White, night = Color.White)
else
ColorProvider(day = getColor(backgroundColor), night = getColor(backgroundColor))

),
modifier = GlanceModifier
.size(30.dp)
.then(
if (isTodayCompleted) {
GlanceModifier.background(
imageProvider = ImageProvider(R.drawable.fab_shape),
colorFilter = ColorFilter.tint(ColorProvider(day = getColor(backgroundColor), night = getColor(backgroundColor)))
) // Apply background when today is completed
} else {
GlanceModifier.background(
imageProvider = ImageProvider(R.drawable.fab_outline),
colorFilter = ColorFilter.tint(ColorProvider(day = getColor(backgroundColor), night = getColor(backgroundColor)))
) // Apply border when today is not completed
}
)
)
}
Column(modifier = GlanceModifier.padding(horizontal = 10.dp))

{
Text("${DateFormat.format("MMMM",today)}",
maxLines = 1,
style = TextStyle(

color = ColorProvider(day = Color.Gray, night = Color.Gray),
fontWeight = FontWeight.Normal,
textAlign = TextAlign.Start,
fontSize = 12.sp))
Text("$title",
maxLines = 1,

style = TextStyle(
color = ColorProvider(day = textColor, night = textColorDark),
fontWeight = FontWeight.Medium,
textAlign = TextAlign.Start,

fontSize = 16.sp))

}

}
Spacer(GlanceModifier.defaultWeight())
Column(
verticalAlignment = Alignment.Vertical.CenterVertically,
horizontalAlignment = Alignment.Horizontal.CenterHorizontally,
) {
Row(
horizontalAlignment = Alignment.Horizontal.CenterHorizontally,
verticalAlignment = Alignment.Vertical.CenterVertically
) {

Text("$currentStreak",

style = TextStyle(
color = ColorProvider(day = textColor, night = textColorDark),
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Start,
fontSize = 14.sp))
Image(
provider = ImageProvider(if (isTodayCompleted)
R.drawable.fire_filled
else R.drawable.fire_outline
), contentDescription = null,
colorFilter = ColorFilter.tint(ColorProvider(day = getColor(backgroundColor), night = getColor(backgroundColor))),
modifier = GlanceModifier.size(14.dp)
)
}
Text(
if (currentStreak.toInt() == 1) "DAY" else
"DAYS",
modifier = GlanceModifier.padding(horizontal = 2.dp),
style = TextStyle(
color = ColorProvider(day = textColor, night = textColorDark),
fontWeight = FontWeight.Normal,
textAlign = TextAlign.Start,
fontSize = 10.sp))
}
}
}


Подробнее здесь: https://stackoverflow.com/questions/792 ... inside-row
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»