我会很乐意为您翻译相关的IT技术内容。以下是需要翻译的内容:
感谢您的提前帮助;)
我想要把一个TextView居中放置在一个TableRow里面,而这个TableRow又在一个TableLayout里面,但是似乎我漏掉了什么,因为TextView并没有被居中显示 :s
以下是我的代码:
private void insertClock() {
TableLayout table = new TableLayout(this);
table.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
table.setStretchAllColumns(true);
TableRow tbRow = new TableRow(this);
TableLayout.LayoutParams layoutRow = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
clock = new TextView(this);
TableRow.LayoutParams layoutHistory = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
clock.setLayoutParams(layoutHistory);
clock.setText(calculateClockText());
tbRow.setLayoutParams(layoutRow);
table.addView(tbRow);
clock.setGravity(Gravity.CENTER_HORIZONTAL);
tbRow.addView(clock);
}
感谢您的提前帮助;)