TableLay中的TableRow内容超出屏幕范围

时间:2011-11-25 16:35:29

标签: android tableview tablerow

我认为这个问题非常简单。

事情是:我的TextView(位于TableLay中的TableRow中)离开可见屏幕。

屏幕截图应该澄清:

yep

我试过

        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[] { "lol@xd.de", "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);

}

}

1 个答案:

答案 0 :(得分:3)