I had the same problem, so I started digging the source code. The main answer is what is called measure() on your SlidingDrawer using MeasureSpec.UNSPECIFIED , meaning SlidingDrawer has the ability to set its own size.
This may be due to the fact that the containing layout (or its parents) is aligned to the base or has WRAP_CONTENT as its height or width. If the containing LinearLayout has baselineAligned true, she asks all her children for their size to find the largest. And, of course, he also asks his children in size if he should wrap them.
Set android:baselineAligned="false" in any LinearLayout that contains a sliding box, and make sure that nothing containing SlidingDrawer has WRAP_CONTENT for height or width. In other words, the SlidingDrawer must have an exact size, which means that its parents must also use FILL_PARENT .
source share