对话框中的Textview被截断

时间:2015-03-08 08:05:14

标签: android textview

我以编程方式将textview放在对话框中。 textview显示文件路径。但是如果文本视频没有出现在对话框中,则textview会切断文本。

TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
    TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT);
TableRow.LayoutParams rowParams = new TableRow.LayoutParams(
    TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT,1f);

TableLayout table = new TableLayout (context);
table.setLayoutParams(tableParams);

TableRow row = new TableRow(context);
row.setLayoutParams(rowParams);

TextView text = new TextView(context);
TextView textTitle = new TextView(context);

textTitle.setText("File path ");
text.setText(name);
text.setLines(1);
text.setSingleLine(true);
text.setHorizontallyScrolling(true);
text.setEllipsize(TruncateAt.MARQUEE);

row.addView(textTitle);
row.addView(text);
table.addView(row);

1 个答案:

答案 0 :(得分:0)

使用以下代码为textview whitch显示路径

textview.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));