Recently in the development of using Recyclerview, stealing a lazy to borrow Android to provide sample in the Divideritendecoration class to do the separation line, did not expect the middle of the separation line does not show the situation, in order to find out the reason, I added a paint in the class, Draw a line in the same place, this line shows, the original divider line is still not shown, it is possible that the Getdrawable method returned is null, so the class parameters modified a bit, the original is Getapplicationcontext (), Now change to GetContext (), the divider line is normal, and finally find out why, because Getapplicationcontext (). The Getdrawable () method is only available after android21, Running this method on the previous version throws a java.lang.NoSuchMethodError:android.content.Context.getDrawable exception, so the separator line does not appear.
The itemdecoration of Recyclerview