How to Add Divider to Android Programmatically Layout
Create View1 or 2 pixels high and wide match_parentand set the background color for whatever color you want the separator to be.
Separate the separator from the elements above and below using the settings margin.
An example :
ImageView divider = new ImageView(this);
LinearLayout.LayoutParams lp =
new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lp.setMargins(left, top, right, bottom);
divider.setLayoutParams(lp);
divider.setBackgroundColor(Color.WHITE);