我以编程方式将 textview 设置为 TableRow View 的 subview ,但我似乎无法让文本包含在父 View 中。
这是应该将文本包装在 TableRow 中的代码。请注意 setSingleLine 被设置为 false。
TextView value = new TextView(this);
![alt text][1]value.setLayoutParams(new TableRow.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
value.setSingleLine(false);
value.setEllipsize(TruncateAt.END);
value.setHorizontallyScrolling(false);
value.setText(txt);
value.setTextColor(Color.BLACK);
value.setTextSize(12);
value.setTypeface(generalFont);
文档没有说将它设置为 false 会使它成为多行,它说它将恢复为默认值。
setSingleLine(boolean singleLine) If true, sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions.
是否有人有指向以编程方式创建的多行 TextView 的代码 fragment 或 URL?
TextView 中的文本
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus tempus porttitor diam, sit amet rutrum nunc laoreet at. Mauris sit amet tristique e
显示问题的图像
最佳答案
问题结束了它成为祖 parent (TableLayout)。我不得不缩小所有列并将文本换行。
table.setShrinkAllColumns(true);
关于Android::TextView::Programitic Creation with setSingleLine(false) - 不换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3704854/