Android Arsenal – Textformatierung

So formatieren Sie Text in Android wie WhatsApp. Jeder Text, der mit angehängt ist s werden fett dargestellt, jeder Text innerhalb von _s wird kursiv dargestellt. Beispiel: “* Hallo Welt!Hallo Welt“ und „Hallo _ Welt!“ „Werden“Hallo die Welt “

Konfiguration

Build-Abhängigkeit hinzufügen

Fügen Sie das JitPack-Repository zu Ihrem root build.gradle am Ende des Repositorys hinzu:

allprojects {
  repositories {
   ...
   maven { url 'https://jitpack.io' }
  }
 }

Abhängigkeit hinzufügen:

dependencies {
         implementation 'com.github.AniruddhaChattopadhyay:TextFormatter:1.0.1'
 }

* Library Functions: 
### 1) FormatText.bold(String text) :
       The function will return a charSequence with *..text..* replaced by the text within *s bolded.
       
### 2) FormatText.italics(String text) :
       The function will return a charSequence with _..text.._ replaced by the text within _s italicized.

### 3) FormatText.boldAndItalics(String text) :
       The function will return a charSequence with texts enclosed in *s and _s replaced by those texts bolded and italicized.
       
### 4) FormatText.colorText(String text,String hexColor,boolean isBackground) :
       The function will return a charSequence with #..text..# replaced by ..text.. colored as hexColor
       (if isBackground is true, the color will be in the ..text.. beckground else the text will be colored with the hexColor.)
       
* Example code: 
```java
        boldText = "*hello* world! Just *Coding*!!";
        italicsText = "_hello_ world! Just _Coding_!!";
        boldItalicsText = "_hello_ world! Just *Coding*!!";
        colorText = "hello world! #Just# Coding!!";

        FormatText.bold(boldText); 
        FormatText.italics(italicsText);
        FormatText.boldAndItalics(boldItalicsText);
        FormatText.colorText(colorText,"#b5bf50",true);
        
        FormatText.colorText(colorText,
                            "#cd001a",
                            false);

Entwickelt von

Aniruddha Chattopadhyay

Fühlen Sie sich frei, neue Funktionen vorzuschlagen, die der Bibliothek hinzugefügt werden sollen.

Lizenz

MIT License

Copyright (c) 2020 Aniruddha Chattopadhyay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.