Let's say I have an activity with two fragments X and Y horizontally placed side by side and one hidden navigation drawer fragment. Whenever I click on a button on the fragment X, the navigation drawer fragment slides from right and takes place above the Y fragment. As I made it transparent, now users can see the X fragment along with the navigation drawer fragment horizontally placed side by side. But this navigation drawer fragment disables the X fragment as it overlays the activity actually. How can I keep the activity transition alive when the navigation drawer is open?
Asked
Active
Viewed 168 times
0
-
1Why do you want to fight against the system? If the Activity should be alive, don't use a navigation drawer. – Henry Apr 18 '16 at 07:04
-
I agree with Henry, but this has been answered here before: http://stackoverflow.com/questions/18743124/make-main-content-area-active-in-drawerlayout – Mike M. Apr 18 '16 at 07:12
-
Henry, I might need to save the state of the fragment Y and replace it every time with the state. That is why, I was thinking about the navigation drawer. Mike, my problem is similar, let me have a look. I could not find the question on stackoverflow. Thanks for suggesting. – Aveek Apr 18 '16 at 07:19
1 Answers
0
Write a custom class for your Navigartion Drawer
public class CustomDrawer extends DrawerLayout {
public CustomDrawer(Context context) {
super(context);
}
public CustomDrawer(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomDrawer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
View drawer = getChildAt(1);
if (getDrawerLockMode(drawer) == LOCK_MODE_LOCKED_OPEN && ev.getRawX() > drawer.getWidth()) {
return false;
} else {
return super.onInterceptTouchEvent(ev);
}
}
}
I had the same question. This code is from here Make fragment clickable when navigation drawer is opened

Community
- 1
- 1

Max Zavernutiy
- 1,771
- 1
- 18
- 27