【发布时间】:2026-01-23 19:45:02
【问题描述】:
当 Textview1 多于一行时,我遇到了一些问题。
示例:textview1 有一行,textview2 显示。
但如果 textview1 多于一行,则 textview2 不会显示,因为 textview1 已满。
还有我的 .xml:
<?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="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:padding="5dp"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginTop="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="@+id/img_vote"
android:src="@drawable/vote_t_1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="xxxxxxdfkldjsklfjsdxxxxxx"
android:id="@+id/tx_poll"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/img_vote"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ttt"
android:id="@+id/tx_count_vote"
android:gravity="center"
android:textColor="@color/color_white"
android:textSize="@dimen/tx_size_smally"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:background="@drawable/bg_count_poll"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/tx_poll"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
如何解决?
【问题讨论】:
-
在你的文本视图上使用椭圆尺寸
-
您在这里使用相对布局有什么特别的原因吗?在这种情况下,我通常更喜欢使用线性布局..
-
您可以将
table-row或linearLayout与权重属性一起使用。 -
@SRBbans 怎么用,请给我举例
-
@ARR.s 看到答案。