我想设置textview
页边距,但以下代码无法显示tablerow
和textview
。怎么了?
TableLayout table = (TableLayout) layoutView.findViewById(R.id.tableLayout1);
table.setStretchAllColumns(true);
for (int i = 0; i < 3; i++) {
TableRow tablerow = new TableRow(layoutView.getContext());
for (int j = 0; j < 3; j++) {
TextView testview = new TextView(layoutView.getContext());
testview.setBackgroundColor(Color.rgb(255, 255, 255));
testview.setTextAppearance(layoutView.getContext(), R.style.TextView_SearchContent);
testview.setText("test");
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.setMargins(1, 1, 1, 1);
testview.setLayoutParams(params);
tablerow.addView(testview);
}
table.addView(tablerow, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}