Панель инструментов не найдена на большом экране с использованием фрагмента

У меня проблема с моим приложением, когда оно находится на большом экране. Я использую фрагмент и всякий раз, когда я запускаю приложение на меньшем экране (5,2 дюйма), отображается панель инструментов, и я могу использовать панель навигации. но когда я запускаю его на большом экране (5,5 дюйма), он внезапно занимает весь экран с панелью инструментов, которую нигде не найти.

Меньший экран:

Меньший экран

Большой экран

Большой экран

Файл макета для app_bar_drawer:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.jjcadiz.omas.Drawer">

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

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

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

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

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    app:srcCompat="@android:drawable/ic_dialog_email" />

1 ответ

<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">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:theme="@style/MyMaterialTheme"
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:text="Purchase Order"
                />
        </android.support.v7.widget.Toolbar>
        <FrameLayout
            android:id="@+id/frame_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/toolbar">
            <LinearLayout 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:layout_width="match_parent"
                android:orientation="vertical"
                android:layout_height="match_parent"
                tools:context=".MainActivity"
                android:weightSum="1"
                android:background="@color/BG_beige">


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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:paddingBottom="5dp">

                        <TextView
                            android:id="@+id/textView3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="Purchase Order"
                            android:textColor="@color/omas_blue"
                            android:layout_gravity="center"
                            android:textSize="25sp"
                            android:gravity="center"/>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="41dp"
                            android:orientation="horizontal">

                            <TextView
                                android:id="@+id/textView5"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Supplier Name:" />

                            <Spinner
                                android:id="@+id/SupplierSpinner"
                                android:layout_width="222dp"
                                android:layout_height="wrap_content" />

                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:orientation="horizontal">

                            <TextView
                                android:id="@+id/textView6"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Date of Transac" />

                            <TextView
                                android:id="@+id/textView4"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1.61"
                                android:text="TextView" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="55dp"
                            android:orientation="horizontal"
                            android:paddingTop="10dp">

                            <TextView
                                android:id="@+id/textView9"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Item name"
                                android:gravity="center"
                                android:layout_gravity="center"/>

                            <TextView
                                android:id="@+id/textView8"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Quantity"
                                android:gravity="center"
                                android:layout_gravity="center"/>

                            <TextView
                                android:id="@+id/textView7"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Unit Price"
                                android:gravity="center"
                                android:layout_gravity="center"/>
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="266dp"
                            android:orientation="horizontal">

                            <EditText
                                android:id="@+id/edtName"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:ems="10"
                                android:inputType="textPersonName"
                                android:hint="Unit Name"/>

                            <EditText
                                android:id="@+id/edtQuantity"
                                android:layout_width="117dp"
                                android:layout_height="wrap_content"
                                android:ems="10"
                                android:inputType="number"
                                android:hint="Quantity" />

                            <EditText
                                android:id="@+id/edtPrice"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:ems="10"
                                android:inputType="numberDecimal"
                                android:hint="Price"/>
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="39dp"
                            android:orientation="horizontal">

                            <TextView
                                android:id="@+id/textView11"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1.99"
                                android:text="Total" />

                            <TextView
                                android:id="@+id/tvTotal"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="PPP" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:orientation="vertical">

                            <TextView
                                android:id="@+id/textView13"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:text="Prepared By:" />

                            <TextView
                                android:id="@+id/tvName"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:text="" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:orientation="horizontal">

                            <Button
                                android:id="@+id/btnConfirm"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Confirm" />

                            <Button
                                android:id="@+id/btnReset"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Reset" />
                        </LinearLayout>

                    </LinearLayout>

                </LinearLayout>
            </ScrollView>
            </LinearLayout>
        </FrameLayout>
    </RelativeLayout>

Используйте этот XML в вашем макете, он будет работать.

Другие вопросы по тегам