【问题标题】:Displaying html string preview in the Layout Editor在布局编辑器中显示 html 字符串预览
【发布时间】:2019-12-07 13:32:52
【问题描述】:

我的 Android 项目的 strings.xml 文件中有这个 html 字符串

Registrandoti confermi di accettare i
        <a href="https://www.google.com/">
            <font color="#FF7860">Termini del Servizio</font>
        </a>
        e
        <a href="https://www.google.com/">
            <font color="#FF7860">l\'Informativa sulla privacy.</font>
        </a>

字符串显示在我的布局文件中的 TextView 中,如下所示:

 <TextView android:layout_width="0dp" android:layout_height="wrap_content"
                  android:text="@string/registration_disclaimer"
                  android:id="@+id/tvRegistrationDisclaimer"
                  android:gravity="center"
                  app:layout_constraintTop_toBottomOf="@+id/button" app:layout_constraintStart_toStartOf="@+id/button"
                  android:layout_marginTop="16dp" app:layout_constraintEnd_toEndOf="@+id/button"/>

我想知道 Android Studio 是否允许在布局中显示带有正确预览的字符串(显示字体颜色和链接),例如 tools:isHtml = true。不幸的是,我无法从官方“tools”文档中找到任何内容。有什么解决办法吗?

【问题讨论】:

  • 预览版不支持

标签: android html android-studio android-layout-editor


【解决方案1】:

我认为它在预览版中不受支持,但是您可以在 yourClass.java 中尝试: yourTextView.setText(Html.fromHtml("string with html format here", Html.FROM_HTML_MODE_COMPACT));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 2016-10-31
    • 2020-11-07
    • 2017-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多