remember9Patch Style Image
fun remember9PatchStyleImage(imageId: String, bitmap: Bitmap, scale: Float? = null, sdf: Boolean = false): StyleImage
Create and remember a StyleImage from a nine-patch Bitmap.
The bitmap must be a nine-patch drawable (.9.png). parse9PatchBitmap is called inside the remember block; it runs once on first composition and is cached for subsequent recompositions as long as the same Bitmap object is passed.
To avoid re-parsing on every recomposition, wrap the bitmap in remember at the call site:
val bitmap = remember { BitmapFactory.decodeResource(resources, R.drawable.my_nine_patch) }
val styleImage = remember9PatchStyleImage(imageId = "my-image", bitmap = bitmap)Content copied to clipboard
Return
Parameters
image Id
the id of the image
bitmap
the nine-patch bitmap as Bitmap; must be a .9.png nine-patch drawable
scale
scale factor for the image
sdf
option to treat whether image is SDF(signed distance field) or not
Throws
if bitmap is not a valid nine-patch drawable