change Img size
- Markwon version: {4.6.2}
When the label has no width information, I want to specify the width of the image to fill the whole screen. What should I do?
thank you
just like this
<p><img src="https://xjej-1256912561.cos.ap-chengdu.myqcloud.com/xinfal200514133952902.png" /></p>
Hello @sunleidehao ,
you can take look at the FitWidthImageSizeResolverSample sample that achieves this with a custom ImageSizeResolver
Hello @noties Where is the FitWidthImageSizeResolverSample?
Hello @hijunmeng ,
this is a file in this repository, you can search for it
hello @noties I tried, but I couldn't find anything.
Hello @hijunmeng ,
sorry, it is not pushed yet 😅
class FitWidthImageSizeResolverSample : MarkwonTextViewSample() {
override fun render() {
val md = """
# Fit Width Image

And some text after and then an inline image that takes full width again: 
""".trimIndent()
val markwon = Markwon.builder(context)
.usePlugin(object : AbstractMarkwonPlugin() {
override fun configureConfiguration(builder: MarkwonConfiguration.Builder) {
builder.imageSizeResolver(FitWidthImageSizeResolver())
}
})
.usePlugin(ImagesPlugin.create())
.build()
markwon.setMarkdown(textView, md)
}
private class FitWidthImageSizeResolver : ImageSizeResolverDef() {
override fun resolveImageSize(drawable: AsyncDrawable): Rect {
return resolveImageSize(
ImageSize(
ImageSize.Dimension(100F, UNIT_PERCENT),
null
),
// important detail - `drawable.result` bounds must be used
drawable.result.bounds,
drawable.lastKnownCanvasWidth,
drawable.lastKnowTextSize
)
}
}
}
Can you send me an example written in Java : FitWidthImageSizeResolver
Thank you very much
Image size remains same in lists also. How can I consider the indent set by list in image width ?