Панель инструментов перекрывая другое содержимое Android - PullRequest
0 голосов
/ 29 сентября 2018

У меня есть BaseActivity, которая содержит навигационный ящик.Итак, теперь мои другие действия будут расширяться от baseActivity, чтобы также получить навигационный ящик.

Это мой макет app_bar

<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"
    android:fitsSystemWindows="true"
    tools:context="com.example.matt_pc.dissertationv2.HomeActivity">


    <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_home"
            android:layout_marginTop="?attr/actionBarSize"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


    <com.andremion.counterfab.CounterFab
        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:backgroundTint="@android:color/white"
        app:srcCompat="@drawable/ic_shopping_cart_black_24dp" />

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

Это мой content_main

<FrameLayout 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/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".HomeActivity"
    tools:showIn="@layout/app_bar_home"
    />

Мой блок навигации.

<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"
    android:background="@mipmap/background"

    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_home"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <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:headerLayout="@layout/nav_header_home"

        android:background="@color/overlayBackground"
        app:itemTextColor="@color/white"
        app:itemIconTint="@android:color/white"
        app:menu="@menu/activity_home_drawer" />

</android.support.v4.widget.DrawerLayout>

Проблема в том, что моя панель инструментов перекрывает мое содержимое. См. Ниже.enter image description here

Любая помощь по этому вопросу?

Ответы [ 2 ]

0 голосов
/ 29 сентября 2018

Я предполагаю, что либо использование двух appbar_scrolling_view_behavior, либо замена Fragment может вызвать проблему.

Итак, если у вас есть что-то подобное в вашем приложении (при попытке показать Fragment):

..replace(android:R.id.content, yourfragment())

Измените представление на FrameLayout id content_frame:

..replace(R.id.content_frame, yourfragment())

и используйте макет следующим образом:

<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true">

    <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>

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <com.andremion.counterfab.CounterFab
        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:backgroundTint="@android:color/white"
        app:srcCompat="@drawable/ic_shopping_cart_black_24dp" />

</android.support.design.widget.CoordinatorLayout>
0 голосов
/ 29 сентября 2018

Попробуйте удалить AppBar тему и панель инструментов popupTheme:

  • android:theme="@style/AppTheme.AppBarOverlay"
  • app:popupTheme="@style/AppTheme.PopupOverlay"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...