【发布时间】:2018-11-21 17:25:53
【问题描述】:
我最近添加了一个TabLayout 包裹在一个之前包含toolbar 的AppBarLayout 中,但现在由TabLayout 托管的片段,应该在它下面,被TabLayout 覆盖,我已尝试将android:layout_below="@+id/tablayout" 添加到我的ViewPager(其中包含片段),并将app:layout_behavior="@string/appbar_scrolling_view_behavior" 添加到TabLayout 本身,但是这两种方法都不起作用,
这是我的布局文件的代码:
<?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.jackz314.todo.MainActivity"
android:id="@+id/total_main_bar"
>
<include
android:id="@+id/include"
layout="@layout/content_main"
app:layout_anchor="@+id/app_bar_layout"
app:layout_anchorGravity="left|bottom"
/>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/app_bar_layout"
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.TabLayout
android:id="@+id/tabs_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:tabMode="fixed"
app:tabGravity="fill" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
请注意,片段的布局包含在“content_main”中,它位于该包含部分中。我对 Android 还是很陌生,因此非常感谢任何形式的帮助或建议。
【问题讨论】:
标签: android-layout android-fragments android-viewpager android-tablayout android-appbarlayout