android - TextView - 在另一个 TextView 的右侧开始一个新行

标签 android textview

enter image description here

我怎样才能让 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>

像这样:

enter image description here

最佳答案

我的猜测是 twitch 应用程序使用 HTML 格式。本质上是使用 HTML 为文本的特定部分设置样式,并将文本的不同部分注入(inject)到一个 TextView 中。

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

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

关于android - TextView - 在另一个 TextView 的右侧开始一个新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58437633/

相关文章:

android - 试图通过网络提供商获得纬度和纬度

android - 新的 PayPal 沙盒测试用户帐户

android - Github 上的问题

导致有线问题的 Android Fragment 返回堆栈

android - 如何在Android的TextView中使文本居中垂直在一行中

java - 找不到符号textView AndroidStudio

c# - 字节数组中的 Unicode 加密文本似乎包含无效字符

android - 如何从 Activity 获取 Widget 的 TextView 的文本?

java - InetAddress.getAllByName() 只接收带有 java.net.preferIPv6Addresses 的 IPv4 地址

android - Android中的垂直(旋转)标签