Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An invisible layout behind the fragment is getting clicked:

I have created several fragments and I add the first fragment the following way:

mainFragment = (MainFragment) MainFragment.create();     getSupportFragmentManager().beginTransaction()     .setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right)     .add(R.id.content, mainFragment, MAIN_FRAGMENT_TAG)     .commit(); 

The second fragment is added this way:

     getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right)     //.hide(mainFragment)     .add(R.id.content,VenueFragment.create(vid), "Venue Fragment")     .addToBackStack(null)     .commit();     setDrawerIndicatorEnabled(false); 

Now as you see the hide method is not applied for this transaction, and the VenueFragment is opened, the problem in this case is that while the VenueFragment opened (and it's a full screen view) pressing on empty section of this fragment invokes calls of the MainFragment clickable views. How can I prevent this?

If I use the hide option then it's not happening but for some reason the animation for removing the MainFragment is going up and that makes a weird experience.

like image 430
Emil Adz Avatar asked Jan 15 '14 15:01

Emil Adz


1 Answers

You need to make the root ViewGroup of VenueFragment clickable so it handles click events and they do not pass down (in the z-order sense) to the other Fragment.

like image 172
Emmanuel Avatar answered Oct 04 '22 19:10

Emmanuel