Попробуйте следующее:
В папке макета, (layout_row. xml)
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/nameTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="center" />
<include layout="@layout/line_horizontal_gray" />
</LinearLayout>
</TableRow>
И для добавления строки в макет таблицы:
private void addRow(final Zone zone){
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
TableRow rowView = (TableRow)inflater.inflate(R.layout.layout_row, null);
TextView textView = rowView.findViewById(R.id.nameTxt);
textView.setText(zone.getName());
textView.setTextColor(Color.BLACK);
textView.setTextSize(25);
layout.addView(rowView);
}
Seperator добавляется в layout_row. Надеюсь, это поможет.
line_horizontal_gray. xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray">
</LinearLayout>