I've sufficed to put the user comment below the username for now, because otherwise the comment appears in a block directly to the right of the username and looks very awkward.包装注释文本
我的问题是,当我注入我的饲料,以用户名的权限的用户评论,整个注释块出现在对。它看起来笨重和尴尬。我想达到类似于Instagram的效果,其中第一行直接出现在用户名后面,第二行和后面的所有行都在它下面。我想知道是否有任何常见的XML技巧将我的评论字符串的第二行和后续所有行都包装在用户名字符串下,就像在Instagram上所做的那样。
我的第二个想法是以编程方式拆分注释对象中的行,并将几个短字符串附加在一起形成一个单一的粘性注释块。
任何有经验的UI开发人员都知道任何技巧?我如何计算用户名的长度?我想只是缩进第一行,但是这样做,只会在你假设每个人都有相同的用户名长度时才起作用,这显然不是一个好的假设。如果没有,有没有人使用后端达到这样的效果?如果是这样,那么开始这样的事情会是一个好的第一方向?
的XML:
<LinearLayout
android:id="@+id/comment1Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp">
<RelativeLayout
android:id="@+id/comment1Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/commentUser1"
tools:text="commentUsername"
android:textColor="#44d7a8"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/commentText1"
tools:text="This is a comment."
android:textColor="#000000"
android:paddingRight="10dp" />
</RelativeLayout>
</Linear Layout>
借口图片的大小 –
你能看看我的第二更新的答案在上面我无法使用HTML或XML,因为字符串是从我的服务器加载的。有什么办法可以直接修改我新连接字符串的第一部分的样式吗?这是感兴趣的一行:new Object [] {commentUser1.getText()。toString()。例如,我可以将字符串的这部分变成粗体还是绿色,或者更好吗? – santafebound