1

I'm building a simple Android app with a viewpager. When I add a floating button in the main activity, he is well placed at the bottom-right of the screen.

But when I add this exact same button inside a fragment of a viewPager, the button goes BEHIND the virtual "soft keys" of my HTC One M8. Look at that (screenshoot with the two buttons):

screenshoot of the app with the floating buttons

So I've find the origin of the problem, but I don't know how to resolve it: the coordinator layout is OK (it stop before the soft keys) but the viewpager inside is not OK (it continues behind the soft keys). How to make it stop at the end of his container, the coordinator layout ? Why the Viewpager is doing that ?

screenshoot of the size of the coordinatorlayout

screenshoot of the size of the viewpager

I share with you the code of the mainActivity, containing the viewpager. I've used "match_parent" so I don't understand why it don't stop at the end of the parent:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">


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

        <android.support.design.widget.CoordinatorLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.design.widget.AppBarLayout
                android:id="@+id/myappbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                app:elevation="0dp">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/mytoolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="?attr/colorPrimary"
                    app:layout_scrollFlags="scroll|enterAlways"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />

                <android.support.design.widget.TabLayout
                    android:id="@+id/mytabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabTextColor="#bcecda"
                    app:tabMode="fixed"
                    app:tabGravity="fill"/>
            </android.support.design.widget.AppBarLayout>

            <android.support.v4.view.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:layout_behavior="@string/appbar_scrolling_view_behavior" />
        </android.support.design.widget.CoordinatorLayout>


        <android.support.design.widget.FloatingActionButton
            android:id="@+id/add_depense_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_margin="16dp" />

    </FrameLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:menu="@menu/drawer_view"
        app:headerLayout="@layout/nav_header" />

</android.support.v4.widget.DrawerLayout>
David D
  • 11
  • 1

0 Answers0