Kimon
05/06/2022, 10:28 AMPiotr Prus
05/07/2022, 3:00 PMKimon
05/10/2022, 8:00 AMmodifier = GlanceModifier.background(imageProvider = ImageProvider(R.drawable.colored_drawable)),
Piotr Prus
05/11/2022, 7:43 AMfun createColorArc(context: Context, colorString: String): Bitmap {
val density = context.resources.displayMetrics.density
val bitmap = Bitmap.createBitmap(
36f.times(density).toInt(),
36f.times(density).toInt(),
Bitmap.Config.ARGB_8888
)
val paintWidth = 3f.times(density)
val paint = Paint().apply {
isAntiAlias = true
color = Color.parseColor(colorString)
strokeWidth = paintWidth
style = Paint.Style.STROKE
strokeCap = Paint.Cap.ROUND
}
val canvas = Canvas(bitmap)
canvas.drawArc(
paintWidth,
paintWidth,
canvas.width.toFloat().minus(paintWidth),
canvas.height.toFloat().minus(paintWidth),
45f,
250f,
false,
paint
)
return bitmap
}
Image(
modifier = GlanceModifier.size(36.dp),
provider = ImageProvider(
bitmap = WidgetUiHelper.createColorArc(
context,
data.colorHex
)
),
contentDescription = "Color arc"
)
Pierre Barbier de Reuille
05/11/2022, 8:22 AMsetElevation
has only been made available to RemoteViews
on Android 12. Prior to this, app widgets can only set their elevation in XML.Kimon
05/13/2022, 2:07 PMsetBackgroundTintList
for tinting background drawables?