why does my toolbar appear below the fragments elements?

1

Well the problem is the following, I have a toolbar that in lolipop versions onwards is shown correctly, but in kit versions kat below, the toolbar is placed below the elements of my fragments I was already investigating and even I have not resolved it

here is my styles.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <!--
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    -->
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>


</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">

</style>




<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">

</style>

and my app_bar_main.xml (caba clarify that I'm using a navegation_drawer)

<?xml version="1.0" encoding="utf-8"?>

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

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:titleTextColor="@color/colorPrimary"
        app:popupTheme="@style/AppTheme"
        app:layout_scrollFlags="scroll|enterAlways"/>

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

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

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

</FrameLayout>

toolbar hidden a bit by the card view

And here you can not even see the toolbar and in later versions it looks perfectly

I wish you could help me ...

Thanks

    
asked by JesusSh 16.11.2017 в 20:39
source

2 answers

1

In this case you can define the FrameLayout below the Toolbar using the property android:layout_below , perform it this way:

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

    android:layout_below="@id/toolbar">

This way the content of the Fragment will always be displayed below the Toolbar .

    
answered by 16.11.2017 в 21:56
0

Perhaps the solution could be to add a LinearLayout with vertical orientation

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

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

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:titleTextColor="@color/colorPrimary"
            app:popupTheme="@style/AppTheme"
            app:layout_scrollFlags="scroll|enterAlways"/>

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

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

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

    </FrameLayout>
    
    
</LinearLayout>
    
answered by 16.11.2017 в 23:37