0
我正在使用包含TableRows的TableLayout。 的TableLayout:未正确处理TextView溢出
<TableLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/window"
android:minWidth="256dp"
android:id="@+id/charStanceList"></TableLayout>
这些行从该XML文件充气:
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="None"
android:id="@+id/stanceHands"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/list_text" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="None"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/stances"
android:textColor="@color/list_text" />
</TableRow>
这里是用来创建行的代码:
public TableRow createTableRow(Context context) {
TableRow row =(TableRow) ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.stance_list_row,null);
TextView hands=(TextView)row.findViewById(R.id.stanceHands);
hands.setText(RHand + LHand);
TextView stancesView =(TextView)row.findViewById(R.id.stances);
MovementMethod movementMethod = stancesView.getMovementMethod();
if ((movementMethod == null) || !(movementMethod instanceof LinkMovementMethod))
{
stancesView.setMovementMethod(LinkMovementMethod.getInstance());
}
SpannableString finalss=new SpannableString("");
for (Stance s : stances) {
SpannableString ss = new SpannableString(s.getName());
class StanceLink extends ClickableSpan{
Stance stance;
@Override
public void onClick(View view) {
Log.i("Clicked", "clicked on stance "+stance.getName()+" of ClassID "+stance.ClassID);
}
public void setStance(Stance st){
stance=st;
}
}
StanceLink link=new StanceLink();
link.setStance(s);
ss.setSpan(link, 0, s.getName().length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE );
finalss= new SpannableString(TextUtils.concat(TextUtils.concat(finalss,ss),"\n"));
}
stancesView.setText(finalss);
return row;
}
下破线当字符串太宽时插入,但其一部分将被隐藏(在右侧)。在这个图像中使用的文本是:武术五本书 - ...的书... “艺术 - ”似乎溢出,所以我们看不到它。 这里的问题是
更改Ellipsize不起作用的屏幕截图。
检查父布局中不能有'layout_width'设置为'wrap_content'。 –
我的TableLayout确实是在一个LinearLayout中有layout_width设置为包装内容,但整个事情在另一个LinearLayout,它有match_parent,是它的问题?在TableLayout之前我有另一个textview,它工作正常... – Lectem