[go: up one dir, main page]

Skip to content

st235/RichTextView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Download

RichTextView

Install

From maven

<dependency>
  <groupId>com.github.st235</groupId>
  <artifactId>richtextview</artifactId>
  <version>0.0.3</version>
  <type>pom</type>
</dependency>

From gradle

implementation 'com.github.st235:richtextview:0.0.3'

Usage

First of all, the library must be initialized. If this step is omitted, the attempt to use will generate an exception.

public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        FontProvider.init(getAssets());
    }
}

View easily configurable from the markup,

    <st235.github.com.richtextview.RichTextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="No more &#xf1e2;"
        android:textSize="22sp"
        app:fontAsset="fontawesome-webfont.ttf"/>

but if you need to download the font manually from the Assets, not everything is lost!

    /**
     * loads the font in the specified path relative to the assets folder.
     * @param fontAsset - font link
     */
    public void loadFont(@Nullable String fontAsset)

Also, you can use the Span to display custom fonts with CustomFontSpan.

    final TextView footer = ...;
    SpannableString footerText = new SpannableString( "\uf0e7 Font Awesome (http://fontawesome.io/)");
    footerText.setSpan(new CustomFontSpan("", "fontawesome-webfont.ttf"), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    footer.setText(footerText);

License

MIT License

Copyright (c) 2018 Alexander Dadukin

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.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Releases

No releases published

Packages

No packages published

Languages