1

I have strange issue while adding/replacing new fragment. My new fragment is outside the screen.

bootom is outside of the display area

This is my fragment container (activity_main.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">

    <FrameLayout
        android:id="@+id/activity_main_fl_full_screen_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </FrameLayout>
</RelativeLayout>

While I`m adding new fragments from activity level, everything is fine. This issue happens only, when I use callback from fragment A/B/C/D... etc. to MainActivity - to add/replace fragment in activity method (method from callback interface).

I noticed, that the problem is gone when I call add/replace method twice, then the first added fragment is outside the screen, but the second one is correct. Second important thing - there is no problem on devices without this android bar at bottom of display area (like Samsung XCover).

bottom bar

Method for adding fragments:

public static void addToBackStack(FragmentManager fm,
                                       Fragment fInstance,
                                       String fragmentTag,
                                       int frameLayoutId) {
        Log.d(TAG, " addToBackStack --> " + fragmentTag);
        FragmentTransaction ft = fm.beginTransaction();

        //ft.replace(frameLayoutId, fInstance, fragmentTag);
        ft.add(frameLayoutId, fInstance, fragmentTag);
        ft.addToBackStack(fragmentTag);

        ft.commit();
}
  • try android:layout_alignParentBottom="true" in your framelayout. – huk Jul 28 '17 at 20:02
  • I have tried, of course, but nothing happend. I even try to put TextView at the bottom of RelativeLayout and align FrameLayout to the top of that TextView. Than the TextView was outside the window... I don`t know how, I fixed the bottom, but then - there was a problem with the top - only using FragmentTransaction.add(); replace method was fine. So I find the solution for the top here: https://stackoverflow.com/questions/29738510/toolbar-overlapping-below-status-bar Just use android:fitsSystemWindows="true" in RelativeLayout – Patryk Karwat Jul 29 '17 at 00:10

0 Answers0