Android富文本编辑器默认字体设置方法及替代插件推荐(jp.wasabeef 1.2.2)
Hey there! I’ve worked with Android rich text editors quite a bit, so let’s break down your questions clearly.
在Android平台为富文本编辑器设置默认字体的方法
Most Android rich text editors are built on top of WebView, so you’ve got a couple of reliable ways to set a default font:
- Use editor-specific API (if available):Some modern editors ship with direct methods like
setDefaultFontFamily()orsetFont(). If your chosen editor has this, it’s the simplest route. - Inject custom CSS (universal approach):For editors based on WebView (like the wasabeef one you’re using), you can inject CSS to override the default font. Here’s how you’d do it with your current plugin:
- First, if you’re using a custom font, place the font file in
assets/fonts/(create the folder if it doesn’t exist). - Define a CSS snippet to load the font and set it as the default:
@font-face { font-family: 'YourCustomFont'; src: url('file:///android_asset/fonts/YourCustomFont-Regular.ttf'); } body { font-family: 'YourCustomFont', sans-serif; }- Apply this CSS to the editor using the
setCss()method:
Even if you’re using a system font (like Roboto), you can skip theRichEditor editor = findViewById(R.id.rich_editor); editor.setCss("your full CSS string here");@font-facepart and just setfont-familydirectly in thebodyselector. - First, if you’re using a custom font, place the font file in
替代jp.wasabeef:richeditor-android:1.2.2的推荐插件
That 1.2.2 version is pretty outdated (last updated around 2017), so it’s no surprise it lacks font customization features. Here are three solid alternatives I’ve used in projects:
- Android-Rich-Text-Editor: A lightweight, WebView-based editor with active maintenance. It supports font family selection, font size adjustment, and all basic formatting (bold, italic, lists, etc.). Setting a default font is straightforward via CSS or dedicated APIs.
- Quill-Android: An Android wrapper for the popular Quill JS editor. It offers advanced formatting options, including font customization, and supports real-time content sync. It’s great if you need a feature-rich editor that matches web-based Quill experiences.
- MaterialRichEditor: A Material Design-compliant editor that comes with built-in UI controls for font selection, color picking, and more. It’s easy to integrate and fits seamlessly into Material-themed apps, plus it supports default font configuration out of the box.
All these plugins are actively maintained, so you’ll get bug fixes and new features over time—something the old wasabeef version can’t offer.
内容的提问来源于stack exchange,提问作者Venkatesh
相关产品推荐
相关产品推荐

