Hyphenation in Android

前端 未结 6 2059
抹茶落季
抹茶落季 2020-12-02 15:36

As part of internationalizing an Android application I have come across the need to dynamically word wrap or hyphenate at the right position.

All my strings are exte

6条回答
  •  孤城傲影
    2020-12-02 16:16

    The following library supports hyphenation. It does all types of text alignment (left/right/center/justified) and hyphenation for you. Not all languages have been added but can be added as necessary. This library uses NO WEBVIEWS and SUPPORTS SPANNABLES and allows for LONG TEXT.

    LIBRARY: https://github.com/bluejamesbond/TextJustify-Android

    ANDROID: 2.2 to 5.X

    SETUP

    DocumentView documentView = addDocumentView(new StringBuilder("Your long text content"), DocumentView.PLAIN_TEXT);
    documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
    documentView.getDocumentLayoutParams().setHyphenator(new Hyphenator(HyphenPattern.PT));
    documentView.getDocumentLayoutParams().setHyphenated(true);
    

提交回复
热议问题