Fragment Over Another Fragment Issue

Fragment over another fragment issue

Set clickable property on the second fragment's view to true. The view will catch the event so that it will not be passed to the main fragment. So if the second fragment's view is a layout, this would be the code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" />

Fragment overlapping each other...and previous fragment is clicking

You're using fragmentTransaction.add(), which won't remove the previous Fragment - use fragmentTransaction.replace() if you want the other Fragment's view to be removed.

Note FragmentManager automatically restores any previously added Fragments when your Activity is recreated (i.e., when savedInstanceState != null). Therefore you'll want to ensure that you only add your initial Fragment once - when the savedInstanceState is null.

if (savedInstanceState == null) {
loadFragment(new FragmentRegLogSkip(), FragmentRegLogSkip.FRAGMENT_KEY);
}

Adding a fragment on top of another fragment onClickListener issue

You can just add the following attribute to the XML root layout of the fragment that agoes on top-

android:clickable="true"

This will ensure that touch events will not propagate further than the top layer.

Fragment overlapping one on another in android

Your second fragment's parent layout must have a background.

PlayQuizSubjectWise XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF" //Here
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >

Invoking a fragment from another fragment and then replacing its layout

To get fragmentManger in fragment use

getActivity().getSupportFragmentManager()

As mentioned You should use R.id.flContent as your frame layout host so use

fragmentTransaction.replace(R.id.flContent, f1);

instead of

fragmentTransaction.replace(R.id.tableLayout1, f1); 


Related Topics



Leave a reply



Submit