【问题标题】:Android LayoutParams do nothingAndroid LayoutParams 什么都不做
【发布时间】:2012-09-11 14:28:40
【问题描述】:

我在 TextView 中遇到了 Android LayoutParams 的问题。我想在大小为 200 dip x 200 dip 的框中显示文本。但什么都没有显示。这是代码:

tr = new TableRow(this);
TextView phone = new TextView(this);
phone.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
phone.setLines(20);
phone.setText(Html.fromHtml("<b>Beschreibung</b><br /><br />"));
phone.append(poi.getDescription());
tr.addView(phone,new ViewGroup.LayoutParams(calculatePxs(200),calculatePxs(200)));
        tr.setPadding(10, 15, 10, 15);

v = new View(this);
v.setBackgroundColor(Color.rgb(51, 51, 51));

table.addView(tr,new TableLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));

table.addView(v,new TableLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT,
                1));

【问题讨论】:

    标签: android textview layoutparams


    【解决方案1】:

    代替

    new ViewGroup.LayoutParams(calculatePxs(200),calculatePxs(200)));
        tr.setPadding(10, 15, 10, 15);
    

    使用 TableRow.LayoutParams

    喜欢:

    new TableRow.LayoutParams(calculatePxs(200),calculatePxs(200)));
    tr.setPadding(10, 15, 10, 15);
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-14
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    • 2012-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多