- 🚀 Migrated project to Gradle 9
- 🔧 Updated Android Gradle Plugin and dependencies
- 🎨 Migrated UI to Material Design 3
- 🧩 Replaced legacy views with modern Material components
- 🌗 Improved light and dark theme consistency
- 🛠 Redesigned formatting toolbar using Material 3 spacing rules
- 🔁 Moved Undo and Redo to bottom tools bar
- 🔄 Fixed source / code toggle to switch both ways correctly
⚠️ Added confirmation dialog before clearing formatting- 🎯 Centralized editor styling using
KnifeTextattributes - 🎨 Applied Material 3 semantic colors instead of hardcoded values
- ✍️ Improved bullets, quotes, and link styling
- ♿ Added tooltips and content descriptions for accessibility
- 👆 Improved touch targets for better usability
- 🧯 Fixed crashes related to editor initialization
- 🧠 Fixed text selection and ActionMode conflicts
- 🔁 Improved undo / redo stability
- 🧹 Cleaned and organized codebase
- 🗑 Removed unused logic and hardcoded strings
Knife (extends EditText) is a lightweight rich text editor component for writing styled documents in Android.
Just select text and apply formatting with a single line of code.
Supports Android 4.0+
Download the demo APK
Explore the source code
More experiments: mthli/Type
bold(boolean valid)→ Apply bolditalic(boolean valid)→ Apply italicunderline(boolean valid)→ Apply underlinestrikethrough(boolean valid)→ Apply strikethroughbullet(boolean valid)→ Apply bullet listquote(boolean valid)→ Apply quote blocklink(String link)→ Apply link to selectionlink(String link, int start, int end)→ Apply link to rangecontains(int FORMAT)→ Check if selection contains formatclearFormats()→ Remove all formattingundo()→ Undo last changeredo()→ Redo changefromHtml()→ Import from HTMLtoHtml()→ Export to HTML
Extend KnifeText for deeper control.
app:bulletColorapp:bulletRadiusapp:bulletGapWidthapp:historyEnableapp:historySizeapp:linkColorapp:linkUnderlineapp:quoteColorapp:quoteStripeWidthapp:quoteGapWidth
Add JitPack repository:
dependencyResolutionManagement {
repositories {
maven { url = uri("https://jitpack.io") }
}
}
Add dependency:
dependencies {
implementation("com.github.mthli:Knife:v1.1")
}
-
Spans, a Powerful Concept
http://flavienlaurent.com/blog/2014/01/31/spans/ -
Spanned | Android Developers
http://developer.android.com/reference/android/text/Spanned.html -
Html.java Source
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/text/Html.java
- https://github.com/neilj/Squire
- https://github.com/SufficientlySecure/html-textview
Copyright 2015 Matthew Lee
Licensed under the Apache License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0
Distributed on an "AS IS" BASIS, without warranties or conditions of any kind.
