TableLayout 内的 TableRow 内容超出屏幕
我想这个问题很简单。
问题是:我的 TextView(位于 TableLayout 中的 TableRow 中)脱离了可见屏幕。
屏幕截图应澄清:
我尝试过
tvValue.setLinksClickable(true);
tvValue.setEllipsize(TruncateAt.MIDDLE);
1) 未应用截断 2)显然,它们显示了链接,但它们不可点击!
由于它是一个高度动态的事情,我需要在代码中完成所有初始化。 所以,这是代码:
public class StartUp extends Activity {
private TableLayout mTableLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Context appContext = getApplicationContext();
mTableLayout = new TableLayout(appContext);
mTableLayout.setBackgroundColor(0xffffffff);
String[] h = new String[] { "email", "facebook", "youtube" };
String[] v = new String[] { "[email protected]", "http://www.facebook.com/010101010101010", "http://www.youtube.com/lalala" };
LayoutParams rowLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
for (int i = 0; i < h.length; ++i) {
TableRow row = new TableRow(appContext);
row.setLayoutParams(rowLayoutParams);
TextView tvHead = new TextView(appContext);
tvHead.setTextColor(0xff336699);
tvHead.setPadding(0, 0, 10, 0);
tvHead.setText(h[i]);
TextView tvValue = new TextView(appContext);
tvValue.setTextColor(0xff191919);
tvValue.setLinksClickable(true);
tvValue.setText(v[i]);
tvValue.setEllipsize(TruncateAt.MIDDLE);
row.addView(tvHead);
row.addView(tvValue);
mTableLayout.addView(row);
}
setContentView(mTableLayout);
}
}
This problem is pretty simple, I think.
The thing is: My TextView (Which is in a TableRow which is in a TableLayout) gets out of the visible screen.
A screenshot should clarify:
I tried
tvValue.setLinksClickable(true);
tvValue.setEllipsize(TruncateAt.MIDDLE);
1) No truncation is applied
2) Obviously, they show links, but they are not clickable!
As its a highly dynamic thing i need to do all initialization in code.
So, here's the code:
public class StartUp extends Activity {
private TableLayout mTableLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Context appContext = getApplicationContext();
mTableLayout = new TableLayout(appContext);
mTableLayout.setBackgroundColor(0xffffffff);
String[] h = new String[] { "email", "facebook", "youtube" };
String[] v = new String[] { "[email protected]", "http://www.facebook.com/010101010101010", "http://www.youtube.com/lalala" };
LayoutParams rowLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
for (int i = 0; i < h.length; ++i) {
TableRow row = new TableRow(appContext);
row.setLayoutParams(rowLayoutParams);
TextView tvHead = new TextView(appContext);
tvHead.setTextColor(0xff336699);
tvHead.setPadding(0, 0, 10, 0);
tvHead.setText(h[i]);
TextView tvValue = new TextView(appContext);
tvValue.setTextColor(0xff191919);
tvValue.setLinksClickable(true);
tvValue.setText(v[i]);
tvValue.setEllipsize(TruncateAt.MIDDLE);
row.addView(tvHead);
row.addView(tvValue);
mTableLayout.addView(row);
}
setContentView(mTableLayout);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试过 setColumnShrinkable() 吗?
http://developer.android.com/参考/android/widget/TableLayout.html#setColumnShrinkable%28int,%20boolean%29
Have you tried setColumnShrinkable()?
http://developer.android.com/reference/android/widget/TableLayout.html#setColumnShrinkable%28int,%20boolean%29