android - 在 Textview 中对齐文本

标签 android textview

尝试对齐文本,但我无法做到这一点我想开始文本从左侧和右侧以相等的边距开始结束。如何做到这一点?

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="20dp"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:lineSpacingExtra="4dp"
        android:layout_marginRight="3dp"
        android:layout_marginLeft="3dp"
        android:paddingBottom="20dp"
        android:text="@string/about_us"
        android:textColor="@color/black"
        android:textSize="15sp"/>
</LinearLayout>

最佳答案

Android 尚不支持两端对齐的文本。

您可以使用外部库来完成您的工作。

我推荐这个:

https://github.com/nikoo28/justify-textview-android

关于android - 在 Textview 中对齐文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42196168/

相关文章:

android - 连续多个 TextView

android - 在 Android 中使文本右浮动

java - 如何在评级栏中设置 float 类型x.5?

android - 无法将调试器用于 xamarin android 项目 : System. IO.FileNotFoundException : Could not load file or assembly Mono. Posix

java - 更改宽度时,Google maps v2 fragment View 会闪烁

java - Android 小部件 relativelayout 无法转换为 android 小部件 textview

java - Android: URL 以 -/\n 结尾的 TextView 链接错误

android - 有历史的EditText

java - 将文件插入 Google 云端硬盘时无法设置文件修改日期

android - 膨胀 gzip HTTP 响应正文时获取 "source exhausted prematurely"