Android的理由TextView的图书馆 [英] Justify android TextView library

查看:211
本文介绍了Android的理由TextView的图书馆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android的证明文本。但我不希望使用Web视图。

I want to justify text in Android. But I don't want to use web view.

我发现文本对齐在下面链接的Andr​​oid库。但我不能使用它。

I find Text Justify Android library on following link. But I can't use it.

请帮我在Android Studio中使用这个库。

Please help me to use this library in Android Studio.

文本库

推荐答案

你说的不能用它是什么意思?有足够清晰的例子如何使用它。

What do you mean by "can't use it" ?? There is clear enough example how to use it.

在xml文件

<com.bluejamesbond.text.DocumentView xmlns:ext="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    ext:documentView_antialias="true"
    ext:documentView_cacheConfig="auto_quality"
    ext:documentView_hyphen="-"
    ext:documentView_lineHeightMultiplier="2.0"
    ext:documentView_maxLines="100"
    ext:documentView_offsetX="10dp"
    ext:documentView_offsetY="10dp"
    ext:documentView_insetPadding="10dp"
    ext:documentView_insetPaddingBottom="10dp"
    ext:documentView_insetPaddingLeft="10dp"
    ext:documentView_insetPaddingRight="10dp"
    ext:documentView_insetPaddingTop="10dp"
    ext:documentView_progressBar="@id/progressBarXml"
    ext:documentView_reverse="false"
    ext:documentView_text="@string/xml_test_data"
    ext:documentView_textAlignment="justified"
    ext:documentView_textColor="@android:color/white"
    ext:documentView_textFormat="plain"
    ext:documentView_textSize="12sp"
    ext:documentView_textStyle="bold|strikeThru|underline"
    ext:documentView_textSubPixel="true"
    ext:documentView_textTypefacePath="fonts/helvetica.ttf"
    ext:documentView_wordSpacingMultiplier="5.0" />

和或者,如果你想动态创建

and or if you want to create dynamically

DocumentView documentView = new DocumentView(this, DocumentView.PLAIN_TEXT);  // Support plain text
documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
documentView.setText("Insert your text here", true); // Set to `true` to enable justification

您可以查看详细信息 Github上的例子页面

[这已经是他们在他们的GitHub库,也是由CommonsWare在评论中提及]

[It is already their in their github repo, also mentioned by CommonsWare in the comment]

只需添加到您的应用程序/的build.gradle

dependencies {
    compile 'com.github.bluejamesbond:textjustify-android:2.1.0'
} 

这篇关于Android的理由TextView的图书馆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆