-1

First i have opened fragment for taking images from camera after taking images display images on another fragment .

But my problem when i open again new fragment by adding then it display first fragment and added new fragment both

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/searchuserLayout" android:background="@color/white" android:clickable="true"> <RelativeLayout android:id="@+id/backButtonRL" android:layout_width="fill_parent" android:layout_height="30dp" android:layout_alignParentTop="true" android:background="@color/action_bar"> <TextView android:id="@+id/backTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerInParent="true" android:layout_centerVertical="true" android:gravity="left" android:layout_marginLeft="10dp" android:text="@string/selfie.cancel" android:textColor="@color/white" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_centerVertical="true" android:gravity="left" android:textStyle="bold" android:text="@string/searchFragment_usersearch" android:textColor="@color/black" /> <TextView android:id="@+id/done" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerInParent="true" android:layout_centerVertical="true" android:gravity="left" android:layout_marginRight="10dp" android:text="@string/done" android:textColor="@color/white" /> </RelativeLayout> <customview.ScrollDetectableListView android:id="@+id/searchlistView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/backButtonRL" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_gravity="center_horizontal" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginBottom="5dp" android:divider="@color/white" android:dividerHeight="1sp"/> </RelativeLayout> 

2 Answers 2

1

Sometimes, Fragment overlap issue occurs when we try to use the different type of fragments( i.e using support fragment's in few fragments and normal fragments in some other fragment ).

Also try setting a background color to your fragment in XML file.

Sign up to request clarification or add additional context in comments.

Comments

0

This happens if you are Using addFragment(); instead of replaceFragment(); during the transaction.this is due to fact that the new fragment will be added above the old one(the old one remains as it is).

So to avoid it you can add a Background(either a color or an image) to your Fragment's view (layout). This will prevent the visibility of fragment below.

You may also see THIS ANSWER for reference.

6 Comments

i have added background color also but it shows me both fragment
could you please post the xml for both the fragments and also u can use Replace instead of add.
SearchUserPollTimeFragment fragment2 = new SearchUserPollTimeFragment(); FragmentManager fragmentManager = getFragmentManager(); Fragment currentFragment = fragmentManager.findFragmentById(R.id.frame_container); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.hide(currentFragment); fragmentTransaction.setCustomAnimations(R.anim.fadein_anim, R.anim.fadeout_anim,R.anim.fadein_anim, R.anim.fadeout_anim); fragmentTransaction.add(R.id.frame_container,fragment2); fragmentTransaction.commit();
i am hidding current fragment and adding new one
please post the xml for the fragments.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.