Android : Toolbar gets pushed back in landscape

on Thursday, December 4, 2014


Within my layout-sw600dp-land folder this layout file is for the main activity the app starts with. Once the app has started, two fragments are programmatically added to the relevant frame layouts.


This current layout causes the toolbar to be pushed back behind both frame layouts.


activity with two fragments with pushed back toolbar


The viewpager fragment and the fragment on the right take up the toolbars space and the toolbar gets pushed back behind them both.



<LinearLayout 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:orientation="horizontal" >

<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="horizontal" >

<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:theme="?attr/ToolBarStyle" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >

<FrameLayout
android:id="@+id/fragment1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingRight="4dp" />

<FrameLayout
android:id="@+id/fragment2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingRight="4dp" />
</LinearLayout>

<include layout="@layout/nav_drawer_layout" />
</android.support.v4.widget.DrawerLayout>

</LinearLayout>


What is the appropriate syntax for a dualpane(fragments) toolbar layout?


0 comments:

Post a Comment