RichTextView


Source link: https://github.com/androidessence/RichTextView

RichTextView Library

This library is an enhancement to the TextView component that allows you to style various spans of text inside the view.

Usage

To have access to the library, add the following dependency to your build.gradle:

 compile 'com.androidessence.lib:richtextview:1.0.4'

Format Types

You can apply any combination of the following formats on a span of text:

  • Bold
  • Italic
  • Underline
  • Strikethrough
  • Superscript
  • Subscript

To use these, use one of the following formatSpan methods:

  • formatSpan(int start, int end, FormatType formatType)
    • This method is used to apply a certain format to a span of text in the RichTextView. Start (inclusive) and end (exclusive) are the indexes of the start and end characters to format.
  • formatSpan(int start, int end, EnumSet<FormatType> formatTypes)
    • This method has the same function as the one above, but allows you to apply a number of FormatTypes to this span of text.
  • formatNumberSpan(int startline, int endline)
    • This method is used to apply NumberSpan based on the start and end line specified.
  • formatBulletSpan(int startline, int endline)
    • This method is used to apply Bullets based on start and end lines.
  • formatImageSpan(int start, int end, Bitmap bitmap)
    • This method is used to apply ImageSpan based on the start and end line specified along with a bitmap specified.
  • formatFadeInSpan(int startIndex, int endIndex)
    • This method fades in text that starts with startIndex and ends with endIndex.

Color Format Types

You can apply the following color formats on a span of text:

  • Foreground (the text color)
  • Highlight (the background color of the span)

To use these formats, use the following method:

  • colorSpan(int start, int end, FormatType formatType, int color)
    • This method functions just as the ones above it, the only difference is that it also requires a color to apply to the span. For example, if you wanted to make the first four characters of text blue, you would use colorSpan(0, 5, FormatType.FOREGROUND, Color.BLUE);

Hyperlinks

You can add a hyperlink to a section of the text using the following method :

  • addHyperlinkToSpan(int start, int end, final String url)
    • This method adds a hyperlink to the text from indices start to end. Clicking on the text will open the browser and load it with the url parameter.`

Sample

Below is a sample of all the possible formats you can apply to a RichTextView. In this example it is all one string, formatted eight different ways.

Credits & Contact

This library was created by Adam McNeilly with special help from:

It is also released under Android Essence blog.

License

The RichTextView library is available under the MIT License. You are free to modify and enhance it in any way. If you submit a pull request, please add your name into the credits section! :)

Resources

Fun to use Floating Action Button (FAB) view for Android 4.0 and higher.

SciChart for Android is a new native Android Charting Library which supports Java and the Android SDK for development of applications and embedded systems that require high performance, real-time Android Charts. With groundbreaking performance and an intuitive, extensible API, SciChart’s Android Chart Library makes impossible projects, possible.

TinyMachine is fun to use finite-state machine. It helps you to write compact and clearly structured code when used in event-driver programming. No deep if-else or switch-case statements, no static state transition tables, no complex, hard to understand models. Just clearly structured state handling and transition logic. This is what TinyMachine is.

This library provides a simple service that allows to display arbitrary text as a system-window overlay.

This library allows to format bank card number automatically, adding a space after every four symbols.

This example project shows how to make imitation of the "double drag" layout.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes