【发布时间】:2016-09-12 15:13:21
【问题描述】:
我在表格行内有三个 textview,但该 textview 的位置未正确对齐,并且我在 tablelayout 的 tablerow 内动态添加 textview,我如何设置 textview 的权重? 请帮帮我
TableLayout table= (TableLayout) findViewById(R.id.table);
TableRow tableRow=new TableRow(this);
TextView txt1=new TextView(this);
txt1.setTextSize(20);
TextView txt2=new TextView(this);
txt2.setTextSize(20);
TextView txt3=new TextView(this);
txt3.setTextSize(20);
txt1.setText("Name");
txt2.setText("Quantity");
txt3.setText("Unit");
tableRow.addView(txt1);
tableRow.addView(txt2);
tableRow.addView(txt3);
table.addView(tableRow);
【问题讨论】:
-
粘贴你的代码
-
听dipali ji,你试过什么?
-
我用基本代码更新问题
标签: android android-studio textview