【问题标题】:How to justify text of TextView in Android如何在Android中证明TextView的文本
【发布时间】:2014-04-29 13:51:04
【问题描述】:

希望你过得好

我想证明我在TextView 中的文本,

有什么办法吗?

提前致谢

【问题讨论】:

标签: xml textview


【解决方案1】:

XML 布局:声明 WebView 而不是 TextView

<WebView
 android:id="@+id/textContent"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content" />

Java代码:设置文本数据到WebView

WebView view = (WebView) findViewById(R.id.textContent);
String text;
text = "<html><body><p align=\"justify\">";
text+= "This is the text will be justified when displayed!!!";
text+= "</p></body></html>";
view.loadData(text, "text/html", "utf-8");

这可能会解决您的问题。

【讨论】:

    【解决方案2】:

    我使用这个项目来证明文本的合理性。它适用于我的项目。 JustifiedTextView

    XML 代码

    <com.codesgood.views.JustifiedTextView
        android:padding="3dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/card_use_hint"/>
    

    结果

    Justified text

    【讨论】:

      猜你喜欢
      • 2016-04-15
      • 2011-01-19
      • 2020-09-06
      • 1970-01-01
      • 2014-02-07
      • 2014-06-05
      • 2012-06-21
      • 2012-08-16
      • 1970-01-01
      相关资源
      最近更新 更多