【问题标题】:Justified Text in ScrollView Android StudioScrollView Android Studio 中的对齐文本
【发布时间】:2017-06-20 04:52:31
【问题描述】:

我想知道是否有人知道如何在 android 中使 TextView 合理,TextView 位于 LinearLayout 的 ScrollView 中。

我在网上看到我可能需要切换到 WebView 才能使其工作。 但是这些帖子似乎有点过时了,也许从那时起 android 实现了一些新的东西

另外,如果有人知道这是否可能,我还需要能够放大 ScrollView。

谢谢!

【问题讨论】:

    标签: android android-webview textview android-scrollview


    【解决方案1】:

    在android中没有直接的方法来证明文本的合理性。你可以在textview.setText()上使用HTML标签;

     <p align="left|right|center|justify">This is some text in a paragraph.</p>
    

    但是中心对齐你可以使用属性-重力

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="paragraph"
        android:gravity="center"
       />
    

    你的 layout_width 应该是 match_parent 以获得正确的结果。

    【讨论】:

    • 嘿,我尝试做这样的事情,但最终没有成功。 String htmltext = " &lt;p align=\"justify\"&gt;"+ secondBeracha.getText() + "&lt;/p&gt;"; secondBeracha.setText(Html.fromHtml( htmltext ));
    【解决方案2】:

    【讨论】:

    • 嘿,我对 android 和编码很陌生。你能解释一下我将如何在我的代码中实现 githun repo 吗?谢谢
    • 嘿,我终于让它工作了!但由于某种原因,文字有点偏离。例子stackoverflow.com/questions/44666058/… 可以看看吗?谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    • 1970-01-01
    • 2017-06-02
    • 1970-01-01
    • 2018-10-12
    相关资源
    最近更新 更多