Я использую макет с AppBarLayout, содержащим панель инструментов и TabLayout, ViewPager и FloatingActionMenu.
Моя проблема заключается в том, что использование AppBarLayout приводит к тому, что другие представления внутри CoordinatorLayout не соответствуют всему экрану при использовании layout_height=match_parent, вместо этого эти другие представления соответствуют тому, что осталось от родителя, за исключением AppBarLayout. Это поведение идеально подходит для моего ViewPager, потому что в противном случае его содержимое было бы покрыто AppBarLayout, но мне нужно, чтобы мой FloatingActionMenu соответствовал всему экрану, чтобы при открытии моего меню я мог затемнить экран.
Итак, мой вопрос: как мне сделать так, чтобы мой FloatingActionMenu занимал весь экран?
Мой XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
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.Home">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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/AppBaseTheme.ToolbarPopup"
app:theme="@style/AppBaseTheme.Toolbar">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:tabTextAppearance="@style/AppBaseTheme.TabText"
app:theme="@style/AppBaseTheme.Toolbar"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/home_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<com.example.FloatingActionMenu
android:id="@+id/fam"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end"
android:padding="@dimen/fab_margin"
app:menu_backgroundColor="#BB8b8b8b">
<com.example.FloatingActionButton
android:id="@+id/fab"
style="@style/MenuButtonsStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</com.example.FloatingActionMenu>
Using a RelativeLayout as my root view or using a LinearLayout to hold my Toolbar and TabLayout would solve my problem, but I need to use CoordinatorLayout and AppBarLayout to add scrolling functionality.
ИЗМЕНИТЬ:
После тестирования на разных устройствах я обнаружил, что эта проблема возникает только на более новых версиях, как вы можете видеть на следующих фотографиях.
В API 23:
android:orientation="vertical"
из панели приложений - person Kosh   schedule 08.01.2016