0

我正在 Android 应用程序中制作一张表格。现在我无法使视图具有相同的高度。

  • 每行有 2 个TextViewstmp_nametmp_content
  • 的高度tmp_content取决于 的长度course_description(i)
  • tmp_content自动设置它的高度。

我想获得的高度tmp_content和重置高度tmp_name相同tmp_content

如果您有任何提示,请告诉我。

for (int i = 0; i < course_name.size(); i++) {
    TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
    lp.setMargins(1, 1, 1, 1);

    TextView tmp_name = new TextView(General.this);
    tmp_name.setText(course_name.get(i));
    tmp_name.setPadding(10, 0, 10, 0);
    tmp_name.setLayoutParams(lp);
    tmp_name.setBackgroundColor(getResources().getColor(R.color.white));

    TextView tmp_content = new TextView(General.this);
    tmp_content.setHorizontallyScrolling(false);
    tmp_content.setPadding(10, 0, 10, 0);
    tmp_content.setLayoutParams(lp);
    tmp_content.setBackgroundColor(getResources().getColor(R.color.white));
    tmp_content.setText(course_discription.get(i));

    TableRow tmp_row = new TableRow(General.this);
    tmp_row.addView(tmp_name);
    tmp_row.addView(tmp_content);
    tmp_row.setGravity(Gravity.CENTER_VERTICAL);

    course_display.removeView(tmp_row);
    course_display.addView(tmp_row);

}
4

0 回答 0