Search code examples
androidkotlinmarkdownandroid-thememarkwon

Markdown how to change the default Text size Android Markwon


Where can I set the configuration to set a custom font and text size for "regular text" while rendering Markdown with the Markwon dependency?

Setting custom multipliers for the headings and setting the codeBlock text sizes don't work. Neither works setting the <item name="android:textAppearance">@style/mytextappearance</item> in the application theme


Solution

  • Nevermind; I found it:

    When building the Markwon instance you do:

    
    Markwon
        .builder(context)
        .usePlugin(object : AbstractMarkwonPlugin(){
              override fun configureSpansFactory(builder: MarkwonSpansFactory.Builder) {
                   super.configureSpansFactory(builder)
                   builder.setFactory(Text::class.java) { _, _ -> TextAppearanceSpan(context, R.style.my_text_style)}
    
              }
        })
        .build()