SimpleDecoratedText


Source link: https://github.com/dsdmsa/SimpleDecoratedtext


SimpleDecoratedText helps you create simple, beautiful, intelligent, responsive TextViews.

Features

  • Clean, intuitive design — With SimpleTextView you can create beautiful text views for you application in a single view

  • Everything on a single TextView — TextDecor class offers a lot of posibilities, adding simple decors to you text : bold, italic, superscript effects to add click listeners on selected texts, change colors, adding shadows and more

  • Out-of-the-box If you need some specific decoration you can add you own by implementing the interface

  • Performant, smoothly scrolling fonts in lists adding fonts to text in lists hav no in pact on you scroll performance

Getting started with SimpleDecoratedtext is super easy! Simply add the dependency to you project and follow the instructions below.

Getting Started

Prerequisites

You're going to need:

  • Gradle or maven — Windows may work, but is unsupported.
  • Android

Getting Set Up

  1. Add the dependency to you project or visit Bintray for details

 compile 'com.dsdmsa.text:text_decor_V01:0.0.5'

or

 <dependency>

<groupId>com.dsdmsa.text</groupId>

<artifactId>text_decor_V01</artifactId>

<version>0.0.5</version>

<type>pom</type>
  </dependency>
  1. Add in your xml Prittytext instead of TextView
 <com.decorator.text.textdecor.PrettyText

android:layout_width="match_parent"

android:layout_margin="10dp"

android:layout_height="match_parent"

android:id="@+id/textDecor"/>
  1. Add some decorations in your code

  TextDecor bold = new TextDecor.Builder()

  .decorate(TextDecor.BOLD)

  .build();

TextDecor fontAndUndeline = new TextDecor.Builder()

  .decorate(TextDecor.font(this,"fonts/Roboto-Thin.ttf"))

  .decorate(TextDecor.UNDERLINE)

  .build();

TextDecor roundRgadient = new TextDecor.Builder()

  .decorate(TextDecor.setRoundBackground(9,2,new LinearGradient(0,0,545,545,Color.CYAN,Color.BLUE, Shader.TileMode.CLAMP),Color.BLACK))

  .decorate(TextDecor.BOLD)

  .build();

TextDecor redBack = new TextDecor.Builder()

  .decorate(TextDecor.BOLD)

  .decorate(TextDecor.setTextColor(Color.RED))

  .decorate(TextDecor.setBackground(Color.BLACK))

  .decorate(TextDecor.absoluteTextSize(50))

  .build();

 TextDecor shadowCol = new TextDecor.Builder()

  .decorate(TextDecor.addShadow(2,2,5,Color.BLACK))

  .decorate(TextDecor.absoluteTextSize(40))

  .build();
  
  1. Get the prittytext from xml :
 prettyText = (PrettyText) findViewById(R.id.textDecor);
  1. And use the decorations with needed text:
prettyText.setText(

  roundRgadient.withText("Lorem Ipsum"),

  fontAndUndeline.withText(" is simply dummy text"),

  " of the printing and typesetting industry.",

  roundRgadient.withText(" Lorem Ipsum "),

  "has been the industry's standard dummy text ever since the ",

  redBack.withText("1500s"),

  shadowCol.withText(", when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the "),

  redBack.withText("1960s"),

  " with the release of ",

  bold.withText("Letraset"),

  " sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of ",

  roundRgadient.withText("Lorem Ipsum")

);

Custom decorations :

  1. For spans woth params use code like this :
  public static Decoration decor(final int param){

return new Decoration() {

 @Override

 public Object newDecorInstance() {

  return new CustomSpan(param);

 
}

}
;
  
}
  1. For simple constant spans :
 public static final Decoration STRINKE = new Decoration() {

@Override

public Object newDecorInstance() {

 return new StrikethroughSpan();

}

  
}
;

TextDecor Decoration list :

  1. UNDERLINE
  2. STRINKE
  3. TRANSPARENT_BACKGROUND
  4. SUBSCRIPT
  5. SUPERSCRIPT
  6. BOLD
  7. ITALIC
  8. ITALIC_BOLD
  9. setBlur(final int radius, final BlurMaskFilter.Blur style)
  10. absoluteTextSize(final int size)
  11. relativeTextSize(final int size)
  12. font(final Context context, final String font)
  13. setTextColor(final int color)
  14. setBackground(final int color)
  15. setRoundBackground(final int corner, final int padding, final int backgroundColor, final int textColor)
  16. addShadow(final float dx, final float dy, final float radius, final int color)
  17. alignRight( )
  18. alignLeft( )
  19. alignCenter( )
  20. replaceTextWithImage(final Context context ,final int id,final int size)
  21. clickableText(final Click click)

Need Help? Found a bug?

Submit an issue to the SimpleDecoratedText Github if you need any help. And, of course, feel free to submit pull requests with bug fixes or changes.

Resources

Using AppAuth library with webview.

A Simple Audio Recorder View with hold to record button and swipe to cancel.

Changing colors of drawable icons by reusing the single icon with different colors.

A library that manages state using RxJava 2.

CurrencyPicker is a simple library that can be show a currency picker.

Android-CustomToast is a powerful & easy to use Custom Toast library for Android. It runs on API level 14 and upwards.

This library provides some predefined custom toast. Also you can coustomize the toast according to your need

A Single line of code can add a beautiful toast message in your app.

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