У меня есть макет деятельности, которая выглядит следующим образом:ViewPager с координатором Layout
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent" />
ViewPager имеет два фрагмента, один с RecyclerView и один с LinearLayout.
Фрагмент с RecyclerView работает так, как ожидалось, и панель действий прокручивается с экрана при прокрутке RecyclerView.
Другой фрагмент с LinearLayout не отображается, как мне бы хотелось. LinearLayout рисуется ниже TabLayout и продолжается за кадром. Я бы хотел, чтобы он изменялся, чтобы заполнить пространство, доступное под TabLayout, без расширения экрана. LinearLayout выглядит так:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/station_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/station_detail_title"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3" />
<include
layout="@layout/station_detail_body"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2" />
</LinearLayout>
<TextView
android:id="@+id/text_view_station_detail_empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal|center_vertical"
android:text="@string/text_view_station_detail_empty"
android:visibility="gone" />
</LinearLayout>
Спасибо за любую помощь, высоко ценится!
Вы решили это? У меня такая же проблема. Благодаря! –
Я никогда не нашел удовлетворительного решения этой проблемы. То, что я закончил, заключалось в добавлении поля к нижней части моего LinearLayout, равного высоте панели приложений. Это держит все на экране, но если панель приложения была свернута от прокрутки одного из других фрагментов, маржа будет видна как пустое место. –