Lingleayout programmatically - How to set up a separator?

I create TextViewsin LinearLayoutprogrammatically and I would like to split them into a delimiter (just a simple line). I am endlessly googled, I found what I can use .setDividerDrawable, but I do not want to use external images for this. Any tips?

+2
source share
3 answers

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);
+9

drawable xml ( ) 9--, -.

LinearLayoutICS, . , .

0

divider android: divider = "some color" Android: showDividers = ""

0

All Articles