在我的表格布局中,我有几行,我想在它们之间画一条水平线,那么我该如何以编程方式进行。
TableLayout resultLayout = new TableLayout(this);
resultLayout.setStretchAllColumns(true);
resultLayout.setShrinkAllColumns(true);
{
// Code to create Registration mark Row
TableRow tableRowRegistrationMark = new TableRow(this);
tableRowRegistrationMark.setGravity(Gravity.CENTER_HORIZONTAL);
TextView textViewRegistartionMark = new TextView(this);
textViewRegistartionMark.setText("Registration mark:");
textViewRegistartionMark.setTextSize(TypedValue.COMPLEX_UNIT_DIP,
12);
textViewRegistartionMark.setTypeface(Typeface.SERIF, Typeface.BOLD);
textViewRegistartionMark.setGravity(Gravity.LEFT);
TextView textViewRegistrationMarkData = new TextView(this);
textViewRegistrationMarkData.setText(strbs[3]);
textViewRegistrationMarkData.setTextSize(
TypedValue.COMPLEX_UNIT_DIP, 12);
textViewRegistrationMarkData.setTypeface(Typeface.SERIF,
Typeface.BOLD);
textViewRegistrationMarkData.setGravity(Gravity.LEFT);
tableRowRegistrationMark.addView(textViewRegistartionMark, 0);
tableRowRegistrationMark.addView(textViewRegistrationMarkData, 1);
// Code to create Make Model Row
TableRow tableRowMakeModel = new TableRow(this);
tableRowMakeModel.setGravity(Gravity.CENTER_HORIZONTAL);
TextView textViewMakeModel = new TextView(this);
textViewMakeModel.setText("Make/Model:");
textViewMakeModel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
textViewMakeModel.setTypeface(Typeface.SERIF, Typeface.BOLD);
textViewMakeModel.setGravity(Gravity.LEFT);
TextView textViewMakeModelData = new TextView(this);
textViewMakeModelData.setText(strddss[1]);
textViewMakeModelData.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
textViewMakeModelData.setTypeface(Typeface.SERIF, Typeface.BOLD);
textViewMakeModelData.setGravity(Gravity.LEFT);
tableRowMakeModel.addView(textViewMakeModel, 0);
tableRowMakeModel.addView(textViewMakeModelData, 1);
// Code to create RowColour
TableRow tableRowColour = new TableRow(this);
tableRowColour.setGravity(Gravity.CENTER_HORIZONTAL);
TextView textViewColour = new TextView(this);
textViewColour.setText("Colour:");
textViewColour.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
textViewColour.setTypeface(Typeface.SERIF, Typeface.BOLD);
textViewColour.setGravity(Gravity.LEFT);
TextView textViewColourData = new TextView(this);
textViewColourData.setText(strddss[2]);
textViewColourData.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
textViewColourData.setTypeface(Typeface.SERIF, Typeface.BOLD);
textViewColourData.setGravity(Gravity.LEFT);
tableRowColour.addView(textViewColour, 0);
tableRowColour.addView(textViewColourData, 1);
// Code to create RowChassisNo
TableRow tableRowChasisNo = new TableRow(this);
tableRowChasisNo.setGravity(Gravity.CENTER_HORIZONTAL);
TextView textViewChasisNo = new TextView(this);
textViewChasisNo.setText("VIN/Chassis No:");
textViewChasisNo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
textViewChasisNo.setTypeface(Typeface.SERIF, Typeface.BOLD);
textViewChasisNo.setGravity(Gravity.LEFT);
TextView textViewChasisNoData = new TextView(this);
textViewChasisNoData.setText(strddss[3]);
textViewChasisNoData.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
textViewChasisNoData.setTypeface(Typeface.SERIF, Typeface.BOLD);
textViewChasisNoData.setGravity(Gravity.LEFT);
tableRowChasisNo.addView(textViewChasisNo, 0);
tableRowChasisNo.addView(textViewChasisNoData, 1);
resultLayout.addView(tableRowRegistrationMark);
resultLayout.addView(tableRowMakeModel);
resultLayout.addView(tableRowColour);
resultLayout.addView(tableRowChasisNo);
resultLayout.addView(tableRowDateofFirstUse);
resultLayout.addView(tableRowTypeofFuel);
}