Use the following code to set the separation line color, invalid, unexpectedly can not see the split line, even if the width of the split line is 100, can not see, from the two lines of code to see, there should be no problem, it is also a very conventional wording.
[Java] view plain copy listview.setdividerheight (1); Listview.setdivider (New colordrawable (Color.gray));
Why not? Look at the source of Setdivider.
[Java] view plain copy public void Setdivider (drawable divider) {if (divider! = null) {Mdivid Erheight = Divider.getintrinsicheight (); } else {mdividerheight = 0; } Mdivider = divider; Mdividerisopaque = Divider = = NULL | | Divider.getopacity () = = Pixelformat.opaque; Requestlayout (); Invalidate (); }
See the code below?
[Java] view plain copy if (divider! = null) {mdividerheight = Divider.getintrinsicheight ();
If the parameter is not empty, to get an internal default height, what is this height, see the code below
[Java] view plain copy public int getintrinsicheight () {return-1; }
Height return-1, you can see the line before the ghost.
From the source code, as long as the ListView Setdivider interface is called, the Mdividerheight will be set to 0 or-1, so you can not see the line, if you want to see the line, it is necessary to call the order in turn, as follows
[Java] view plain copy listview.setdivider (new Colordrawable (Color.gray)); Listview.setdividerheight (1);
Here, do not comment on its source code, but personally think such logic is really inappropriate, set the color should not be set up the basic parameters have been modified.