【问题标题】:How to set equal width to multiple textviews irrespective of word count aligned vertically in android?无论在android中垂直对齐的字数如何,如何为多个文本视图设置相等的宽度?
【发布时间】:2019-11-14 13:16:31
【问题描述】:

正如您在附图中看到的那样,第 1 行有两个单词,第 2 行有 4 个单词,最后一行有一个单词。 但无论文本大小和字数如何,它们都具有相同的宽度。谁能帮我实现这一目标?

【问题讨论】:

    标签: android text-alignment richtext text-formatting text-styling


    【解决方案1】:

    使用AppCompatTextView并设置android:autoSizeTextType="uniform"android:maxLines="1"

     <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/textView"
            android:layout_width="400dp" <!--fixed size-->
            android:layout_height="200dp" <!--fixed size-->
            android:autoSizeTextType="uniform"
            android:maxLines="1"/>
    

    【讨论】:

    • 我已经尝试了上面的代码来实现这个东西,它没有成功。你能帮忙解决一下吗?
    • @JohnSmith 你的 TextView 中 widthheight 的值是多少?
    • @JohnSmith 将 height 设置为更高的值
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-18
    • 1970-01-01
    • 1970-01-01
    • 2011-08-30
    • 2014-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多