Search code examples
androidandroid-tablayout

Tablayout is ruined after changing compile sdk version from 23 to 24


I already had an app with a perfectly working tablayout.But after changing the compile sdk version from 23 to 24 a small gap appears in the second tab.

It should look like this.

first tab is correct

But it looks like this,with the black gap.

error tab

Can anyone tell me how to fix this

Both these tabs use the same layout.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout   xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" tools:openDrawer="start">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
        android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">


    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/dashboard" />


</android.support.design.widget.CoordinatorLayout>

<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:itemTextColor="@color/drawer_text_color"
    app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" />

dashboard.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp">

<ProgressBar
    android:id="@+id/progbar"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_gravity="center"
    />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    >
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/txt"
      android:text="These are your active court Proceedings"
      android:paddingBottom="10dp"/>
   <android.support.v7.widget.RecyclerView
      android:id="@+id/recycler_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#D9DCDE"
      android:scrollbars="vertical">
   </android.support.v7.widget.RecyclerView>
</LinearLayout>
</FrameLayout>

I hope my question is clear.Please give me a solution for this. Thanks.


Solution

  • From the Documentation

    android:fitsSystemWindows

    Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.

    so set *android:fitsSystemWindows = "false" for DrawerLayout and CoordinatorLayout

        <?xml version="1.0" encoding="utf-8"?>
    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="false"
        tools:openDrawer="start">
    
        <android.support.design.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="false"
            tools:context=".MainActivity">
    
        </android.support.design.widget.CoordinatorLayout>
    </android.support.v4.widget.DrawerLayout>