GridLayout gv = (GridLayout) findViewById(R.id.gridlayout);TextView tv = new TextView(context);tv.setGravity(Gravity.CENTER_HORIZonTAL | Gravity.TOP);tv.setText("TextView);LayoutParams params = new LayoutParams(Set your column and row information as params);tv.setLayoutParams(params);gv.addView(tv);您不能将代码粘贴到其中,并且需要对其进行测试和更改以使其适合(它不仅会起作用)。但这应该给您大致的想法。



