SimpleDecoratedText helps you create simple, beautiful, intelligent, responsive TextViews.
<img src="https://s26.postimg.org/kurrj1u5l/Screenshot_2016_08_25_15_07_15.png" width=350>
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
- 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>
- 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"/>
-
Add some decorations in your code ```java 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();
4. Get the prittytext from xml :
```java
prettyText = (PrettyText) findViewById(R.id.textDecor);
- 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 :
- 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); } }; }
- For simple constant spans :
public static final Decoration STRINKE = new Decoration() { @Override public Object newDecorInstance() { return new StrikethroughSpan(); } };
TextDecor Decoration list :
- UNDERLINE
- STRINKE
- TRANSPARENT_BACKGROUND
- SUBSCRIPT
- SUPERSCRIPT
- BOLD
- ITALIC
- ITALIC_BOLD
- setBlur(final int radius, final BlurMaskFilter.Blur style)
- absoluteTextSize(final int size)
- relativeTextSize(final int size)
- font(final Context context, final String font)
- setTextColor(final int color)
- setBackground(final int color)
- setRoundBackground(final int corner, final int padding, final int backgroundColor, final int textColor)
- addShadow(final float dx, final float dy, final float radius, final int color)
- alignRight( )
- alignLeft( )
- alignCenter( )
- replaceTextWithImage(final Context context ,final int id,final int size)
- 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.