Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange margin above entire layout

My app uses one activity with a ViewPager to swap fragments for the app pages. Every other fragment works, but for some reason, one of them, my settings fragment, doesn't. The following image illustrates this. The red area is the unwanted margin. The blue area is a toolbar that is defined in the main activity layout - it is always there. The green area is the main ViewPager, also defined in the main activity layout:

enter image description here

This is what the MainActivity layout looks like:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.MainActivity"
android:fitsSystemWindows="true" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- Tab Bar -->
    <com.rentalapp.rentmi.views.SlidingTabLayout
        android:id="@+id/main_content_pager_tab_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:background="@color/primary" />

    <!-- Content Pager -->
    <android.support.v4.view.ViewPager
        android:id="@+id/main_content_pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/main_content_pager_tab_bar" />

</RelativeLayout>

</RelativeLayout>

And this is what the Settings fragment looks like:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Settings"
        android:id="@+id/textView2"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:paddingTop="10dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Log Out"
        android:id="@+id/logout"
        android:layout_below="@+id/textView2"
        android:layout_centerHorizontal="true"
        android:paddingTop="10dp" />

</RelativeLayout>

How do I fix this unwanted margin? If I remove android:fitsSystemWindows="true" from the main layout, then every other page gets the notification bar drawn on top of the tab bar, which I do not want.

like image 538
Dooskington Avatar asked Jan 06 '23 00:01

Dooskington


1 Answers

Not sure how, but I was able to fix it by removing the one android:fitsSystemWindows="true" that I had. Removing that in the past broke everything. Now it fixed it.

like image 96
Dooskington Avatar answered Jan 11 '23 03:01

Dooskington