【问题标题】:TextView - Starting a new line while it's to the right of another textviewTextView - 在另一个文本视图的右侧开始一个新行
【发布时间】:2019-10-17 17:08:50
【问题描述】:

如何让 textview 从左侧开始新行,同时保留属性“toTheRightOf”username25?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/model_rv_videoactivity_username"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="username25:"
        android:textStyle="bold"
        android:paddingLeft="12dp"
        android:paddingRight="6dp"/>
    <TextView
        android:id="@+id/model_rv_videoactivity_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/colorBlackFont"
        android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        android:layout_toRightOf="@+id/model_rv_videoactivity_username"/>

</RelativeLayout>

像这样:

【问题讨论】:

    标签: android textview


    【解决方案1】:

    我的猜测是 twitch 应用程序使用了 HTML 格式。本质上是使用 HTML 来设置文本的特定部分的样式,并将其不同部分注入到一个文本视图中。

    也许看看这个: https://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String,%20int)

    您可以使用 HTMl 设置字符串的 username25: 部分的样式,然后在一个文本视图中将消息部分与其全部连接起来。

    【讨论】:

    猜你喜欢
    • 2012-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-11
    • 2017-06-05
    • 2023-03-08
    相关资源
    最近更新 更多