Skip to content Skip to sidebar Skip to footer

Tab Layout Covering Parts Of Fragment, Layout_below Not Working

So I have a UserAreaActivity that has a layout with tabLayout. Each one of the tabs is its own fragment, however in each fragments layout the tabLayout covers the top of the fragme

Solution 1:

As @Mike M pointed out, add the attribute "layout_below" in your ViewPager. And give an ID to your AppBarLayout. Your UserAreaActivity.xml will look like this.

<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:app="http://schemas.android.com/apk/res-auto"xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/activity_user_area"android:layout_width="match_parent"android:layout_height="match_parent"tools:context="com.example.aleksandr.godspeedinvestments.UserAreaActivity"><android.support.design.widget.AppBarLayoutandroid:layout_height="wrap_content"android:layout_width="match_parent"android:id="@+id/toolbarLayout"android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    ><includeandroid:layout_height="wrap_content"android:layout_width="match_parent"layout="@layout/toolbar_layout"
       /><android.support.design.widget.TabLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/tabLayout"app:tabMode="fixed"app:tabGravity="fill"app:tabTextAppearance="@style/MyTabStyle"
        ></android.support.design.widget.TabLayout></android.support.design.widget.AppBarLayout><android.support.v4.view.ViewPagerandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_below="@+id/toolbarLayout"android:id="@+id/viewPager"
    ></android.support.v4.view.ViewPager></RelativeLayout>

Solution 2:

Adding the attribute app:layout_behavior="@string/appbar_scrolling_view_behavior" to the ViewPager worked for me. If it's not in your string file already, the value is android.support.design.widget.AppBarLayout$ScrollingViewBehavior

Post a Comment for "Tab Layout Covering Parts Of Fragment, Layout_below Not Working"