I recently started using the DrawerLayout in a new project about a week ago and it\'s all working fine. Apart from the odd times when swiping it in and out with my finger it
I think I've managed to fix this by creating my own copies of the files I needed from the support library source code and catching the null View in isContentView()
.
The files I needed from the source were:
I put them in their own package in my project and renamed DrawerLayout
to FixedDrawerLayout
. (So I can easily tell which copy of the DrawerLayout I'm using)
I then changed isContentView()
to:
boolean isContentView(View child) {
if(child == null){
return false;
}
return ((LayoutParams) child.getLayoutParams()).gravity == Gravity.NO_GRAVITY;
}
After swapping all references to the DrawerLayout
in my Activity
to FixedDrawerLayout
it seems to have fixed it.
Not sure if there is anything that can happen by just returning false
in isContentView()
, but it doesn't crash anymore and it's still usable even when child
is null.