【问题标题】:How to Justify the text and align properly in textview in android如何在android的textview中对齐文本并正确对齐
【发布时间】:2018-07-31 17:37:57
【问题描述】:

我在xml 中有一个TextView,但我在java 中给出了TextView 值。同时显示其不正确的对齐方式。请您提供解决方案。

Xml 中,我给出的值意味着它显示正确,但在 java 中,我给出的值没有以正确的方式显示。我想证明文本的合理性

    <TextView 
    android:text="" android:id="@+id/result"
    android:layout_marginTop="13dp"
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="left|center|right" 
    android:gravity="left|center|right" 
    android:textStyle="bold" 
    android:textAlignment="center" 
    android:layout_marginRight="5dp" 
    android:layout_marginLeft="5dp"
    android:textSize="15dp" />

【问题讨论】:

标签: android textview alignment


【解决方案1】:

您只需要添加此代码

 android:justificationMode="inter_word"

【讨论】:

    【解决方案2】:

    Android 0 支持 TextView 的对齐方式。请点击以下链接

    您还可以使用以下库进行文本对齐。

    希望对你有帮助

    【讨论】:

    • 感谢您的解决方案。它工作正常。我无法接受答案
    • @kalaivani,你能再试一次吗?
    • @kalaivani 你已经支持了我的回答,如果它对你有帮助,你也可以接受我的回答。谢谢。
    • 感谢您的解决方案。我发布了另一个问题。您能帮我解决问题吗。我在 android 中运行 cordova ionic 项目文件夹
    猜你喜欢
    • 2013-02-11
    • 2020-09-06
    • 2021-05-01
    • 1970-01-01
    • 2017-11-06
    • 2012-06-21
    • 2012-02-16
    • 2012-08-16
    相关资源
    最近更新 更多