我有一个非常简单的ListView行:的RelativeLayout textviews重叠
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tournament_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize="25dp" />
<TextView
android:id="@+id/tournament_winner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="25dp" />
</RelativeLayout>
当"@+id/tournament_name"
文长 - 它从"@+id/tournament_winner"
的一个重叠,我不明白为什么。
我试过使用android:singleLine="false"
无济于事。我也尝试使用android:inputType="textMultiLine"
作为文件说android:singleLine="false"
已弃用,但后来我得到警告:Attribute android:inputType should not be used with <TextView>: Change element type to <EditText> ?
所以这里也没有好处。
我也试过使用android:ellipsize="end"
但这不起作用。我认为这是因为左侧TextView ("@+id/tournament_name")
中的文字不足以填满ListView
的全部宽度(该代码在此处未播种)。
我确定如果我使用android:layout_width="wrap_content"
这两个TextView字段不应该重叠。
下面是一个例子(见第二行):
任何进一步想法如何这可以是固定的?
这不会导致编译时出错吗? tournament_winner现在还不存在,那么如何将任何东西与它对齐呢? – Vas
这是在答案这里解决:https://stackoverflow.com/a/11594737/369480你需要确保你在ID中指定一个+。 – gnuf
ndroid的荣誉:layout_toLeftOf =“@ id/tournament_winner”。它的工作原理 –