In this guide you will clone the MCBFC repository, confirm that your local toolchain meets the prerequisites, and run the sample app on a real device or emulator — all so you can see copy buttons appearing on every fenced code block in action. Once the demo is running, the integration section walks you through transplanting the same pattern into your own Android project.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/mcbfc/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before you begin, make sure you have the following installed and configured:
- Android Studio (latest stable recommended) — the easiest way to build and run the project.
- JDK 21 with Kotlin support — required by the Gradle toolchain. Confirm with
java -version. - Gradle 9.4.1 — the repository ships with a Gradle wrapper (
gradlew/gradlew.bat) that downloads the correct version automatically, so a local Gradle installation is optional. - Android device or emulator running API level 24 or higher (Android 7.0 Nougat+).
Clone and set up
(Optional) verify the Gradle wrapper version
The repository includes a pre-configured wrapper targeting Gradle 9.4.1. You can confirm it before building:The output should show
Gradle 9.4.1. On Windows, use gradlew.bat --version.Build options
- Android Studio
- CLI
- In Android Studio, choose File → Open and select the
mcbfcdirectory. - Wait for the Gradle sync to complete (the IDE will download dependencies automatically).
- Select your target device or emulator from the device dropdown.
- Click the Run ▶ button (or use Build → Make Project) to assemble and deploy the debug build.
Integrate into your own project
MCBFC is a reference implementation — there is no library artifact to add as a dependency. Follow these steps to bring the pattern into an existing Android project.Add the Markwon dependencies
Open your module’s Sync your project after saving the file.
build.gradle.kts and add the two Markwon artifacts inside the dependencies block:Copy BlockCodeEntry.kt and the fenced code layout
Copy
app/src/main/java/com/srm/markdown_render/BlockCodeEntry.kt into your own package and update the package declaration at the top of the file.Then copy app/src/main/res/layout/fenced_code_view.xml into your project’s res/layout/ directory. This layout contains the HorizontalScrollView-wrapped TextView (R.id.command) and the overlay ImageButton (R.id.copyCommand) that BlockCodeEntry.Holder references. Adjust the styling — fonts, colours, padding — to match your app’s design system.Copy markdown.kt and the default entry layout
Copy
app/src/main/java/com/srm/markdown_render/markdown.kt into your package (update the package declaration). This class owns the Markwon instance and MarkwonAdapter, registers BlockCodeEntry for all FencedCodeBlock nodes, and configures the RecyclerView.Also copy app/src/main/res/layout/adapter_default_entry.xml — this is the fallback layout passed to MarkwonAdapter.builderTextViewIsRoot(...) for every non-code node.Wire up in your Activity or Fragment
In your
Activity (or Fragment’s onViewCreated), instantiate the markdown wrapper and call sett() with your markdown string:sett() calls adapter.setMarkdown() followed by notifyDataSetChanged() internally, so a single call is all that is needed to render or refresh the content.