首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >安卓设计支持TabLayout重叠内容

安卓设计支持TabLayout重叠内容
EN

Stack Overflow用户
提问于 2015-06-06 03:49:45
回答 1查看 6.2K关注 0票数 16

我使用的是设计支持库中引入的新TabLayout。我有这样的代码:

代码语言:javascript
复制
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/lines_coordinator"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:elevation="4dp"/>

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

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

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

</LinearLayout>

问题是,标签与片段显示的内容的顶部重叠。我该如何解决这个问题呢?我使用的TabLayout和Github上的例子一样,所以我相信我的代码没有问题。我已经有了一个工具栏,因为我在导航抽屉中使用片段中的选项卡,所以我从AppBarLayout中删除了它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-06 04:12:28

您需要将app:layout_behavior="@string/appbar_scrolling_view_behavior"添加到您的ViewPager:这会将视图的高度更改为低于AppBarLayout,而不是整个match_parent高度。

票数 48
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30674648

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档