【发布时间】:2013-03-18 13:41:15
【问题描述】:
我必须在 Android 中显示来自xml 提要的Textview。
让我们把这是我的Textview:
Mallika Sherawat's upcoming movie Dirty Politics
这里我为这些Textview动态创建了布局:
LinearLayout.LayoutParams textLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 50);
textLayoutParams.gravity = Gravity.CENTER;
TextView tv = new TextView(this);
tv.setSingleLine(false);
tv.setEllipsize(null);
tv.setHorizontallyScrolling(false);
tv.setTextColor(Color.parseColor("#a7a9ac"));
tv.setText(Appscontent.Sub_arraylisttwo.get(j));
tv.setLayoutParams(textLayoutParams);
tv.setBackgroundColor(Color.parseColor("#414042"));
我在这里提到了宽度 50。
所以文本在小内容Textview上显示得很好。有时我有更多内容Textview,这意味着我如何显示Textview,如下所示:
Mallika Sherawat's
upcoming movie Dirty...
我的意思是文本必须在文本扩展后显示最多 2 行,这意味着只需添加 ... 内容,如上例所示。我该怎么做?
【问题讨论】:
标签: android textview word-wrap