Skip to content

Instantly share code, notes, and snippets.

@goncalossilva
Last active December 18, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goncalossilva/5856947 to your computer and use it in GitHub Desktop.
Save goncalossilva/5856947 to your computer and use it in GitHub Desktop.
class MyDrawerLayout extends DrawerLayout {
// ...
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if(child instanceof ViewGroup) {
ViewGroup childVG = (ViewGroup)child;
if(childVG.getBackground() == null && childVG.getChildCount() == 1) {
View realChild = childVG.getChildAt(0);
ViewGroup.LayoutParams lp = realChild.getLayoutParams();
if(realChild.getBackground() != null
&& lp.width == ViewGroup.LayoutParams.MATCH_PARENT
&& lp.height == ViewGroup.LayoutParams.MATCH_PARENT) {
child.setBackgroundDrawable(realChild.getBackground());
realChild.setBackgroundDrawable(null);
}
}
}
super.addView(child, index, params);
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment