jjzjj

Android Toolbar 在 CollapsingToolbarLayout 中重叠 TabLayout

coder 2023-12-01 原文

我正在尝试使 CollapsingToolbarLayoutToolbarTabLayout 在其下方,但它们相互重叠,我得到 this

我已经尝试了很多解决方案,但仍然有这个问题。这是我的 xml:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="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:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/colorAppPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <RelativeLayout
                android:id="@+id/image"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:background="@drawable/material_plane"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/header_png"
                app:layout_collapseMode="parallax"
                app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

                <ImageView
                    android:id="@+id/imageViewPhoto"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_centerInParent="true" />

                <TextView
                    android:id="@+id/textViewName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="false"
                    android:layout_below="@+id/imageViewPhoto"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="5dp"
                    android:text="TEXT"
                    android:textColor="@color/white"
                    android:textSize="16dp" />
            </RelativeLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:fitsSystemWindows="true"
                android:gravity="top"
                app:layout_collapseMode="pin"
                app:layout_scrollFlags="scroll|enterAlways">

                <TextView
                    android:id="@+id/toolbar_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textColor="@color/white"
                    android:textSize="20dp"
                    android:textStyle="bold" />
            </android.support.v7.widget.Toolbar>

            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="bottom"
                android:fitsSystemWindows="true"
                app:tabBackground="@android:color/transparent"
                app:tabMode="scrollable" />

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

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

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

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

最佳答案

尝试从您的 RelativeLayout 中删除它:

app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

或者让他们像这样:

app:layout_scrollFlags="scroll|enterAlwaysCollapsed">

我猜这是一个错误。


更新:检查此链接:http://blog.grafixartist.com/parallax-scrolling-tabs-design-support-library/

类似的问题:How to use a TabLayout with Toolbar inside CollapsingToolbarLayout?

<android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:contentScrim="@color/colorPrimaryDark"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <RelativeLayout
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:background="@drawable/header"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop">

            <ImageView
                android:id="@+id/imageViewPhoto"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_centerInParent="true"
                app:layout_collapseMode="parallax" />

            <TextView
                android:id="@+id/textViewName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="false"
                android:layout_below="@+id/imageViewPhoto"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="5dp"
                android:text="TEXT"
                android:textSize="16dp" />

        </RelativeLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:fitsSystemWindows="true"
            android:gravity="top"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|enterAlways">

            <TextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:textSize="20dp"
                android:textStyle="bold" />
        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/htab_tabs"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_gravity="bottom"
            app:tabIndicatorColor="@android:color/white" />

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

关于Android Toolbar 在 CollapsingToolbarLayout 中重叠 TabLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35223025/

有关Android Toolbar 在 CollapsingToolbarLayout 中重叠 TabLayout的更多相关文章

  1. ruby - 查找重叠的正则表达式匹配项 - 2

    我想找到给定字符串中的所有匹配项,包括重叠匹配项。我怎样才能实现它?#Example"a-b-c-d".???(/\w-\w/)#=>["a-b","b-c","c-d"]expected#Solutionwithoutoverlappedresults"a-b-c-d".scan(/\w-\w/)#=>["a-b","c-d"],but"b-c"ismissing 最佳答案 在积极的前瞻中使用捕获:"a-b-c-d".scan(/(?=(\w-\w))/).flatten#=>["a-b","b-c","c-d"]参见Rubyde

  2. ruby - 确定字符串的结尾是否与单独的字符串的开头重叠 - 2

    我想查找字符串的结尾是否与单独字符串的开头重叠。例如,如果我有这两个字符串:string_1='Peoplesaynothingisimpossible,butI'string_2='butIdonothingeveryday.'如何找到string_1末尾的“butI”部分与string_2开头相同?我可以编写一个方法来遍历这两个字符串,但我希望得到一个包含我错过的Ruby字符串方法或Ruby习惯用法的答案。 最佳答案 将MARKER设置为一些从未出现在您的string_1和string_2中的字符串。有一些方法可以动态地做到这一

  3. ruby - 检查 ruby 中的两个范围是否重叠 - 2

    我知道我能做到:(1..30).cover?(2)=>true但是当我尝试对另一个范围执行相同操作时,它总是返回false:(1..30).cover?(2..3)=>false所以我的问题是-是否有任何优雅的方法来比较ruby​​中的两个范围?在我的例子中,我想检查两个日期时间范围是否重叠。提前致谢。 最佳答案 给定范围A的两个范围重叠,当:范围B从范围A开始,范围B在范围A内结束或范围B在范围A之前开始,在范围A之后结束例子:RangeA|-----||-----|Case1|-----|Case2|-|Case1+2|----

  4. ruby - 如何测试两个时间范围是否重叠? - 2

    我需要实现预订功能并确保预订不会在Rails应用中重叠。cover?和between?方法并不是我所需要的。与同一模型上的其他潜在范围相比,我必须确保时间范围的唯一性,并且要高效地做到这一点。我认为可以使用overlaps?来完成.问题是,对于这样的事情,它会返回TRUE:(1..5).overlaps?(5..9)=>true如果我比较一个预订在另一个预订开始时结束(3:30-4:00与4:00-4:30),它会说他们做重叠,但他们在技术上没有。那会有问题吗?ValidatesOverlap似乎可以解决这个问题,包括边缘重叠。有什么建议吗? 最佳答案

  5. ruby - Array#slice 的重叠等效项 - 2

    这个问题在这里已经有了答案:Rubyarrayaccess2consecutive(chained)elementsatatime(4个答案)关闭3年前。给定这个Ruby数组:[1,2,3,4,5]像这样迭代它的最简单方法是什么?[[1,2],[2,3],[3,4],[4,5]]还是这个?[[1,2,3],[2,3,4],[3,4,5]]

  6. ruby - 续集连接表,但我有重叠的列名。如何为这些列名称起别名? - 2

    这是我连接两个表的代码:DB.from(:sources).join(:payloads,:source_id=>:id)表名是:sources,:payloads。问题是有效负载中有一个:id列覆盖了:sources中的:id列。我需要使用别名,以便我只获得一个包含所有列名的大型表。然而,正如目前所写的和我的表目前的结构,:id列正在合并,第二个表优先。这有意义吗?如何创建别名,以便:sources中的:id列仍然显示? 最佳答案 要将sources.id别名为其他名称,请使用Identifieraliases..select_a

  7. ruby-on-rails - 在 Rails 中查找与范围重叠的记录 - 2

    所以,我有一个Event模型,它有一个starts_at和一个ends_at列,我想找到发生在日期范围。我想出了这个named_scope(range通常是一个月):named_scope:in_range,lambda{|range|{:conditions=>['starts_atBETWEEN?AND?ORends_atBETWEEN?AND?',range.first,range.last,range.first,range.last]}}按预期工作。但是如果一个事件在之前的一个月开始并且在范围之后的一个月结束,它就不会显示。有没有办法以正确的方式找到这些事件?

  8. ruby-on-rails - 如何组合重叠的时间范围(时间范围联合) - 2

    我有一个包含多个时间范围的数组:[Tue,24May201108:00:00CEST+02:00..Tue,24May201113:00:00CEST+02:00,Tue,24May201116:30:00CEST+02:00..Tue,24May201118:00:00CEST+02:00,Tue,24May201108:00:00CEST+02:00..Tue,24May201109:00:00CEST+02:00,Tue,24May201115:30:00CEST+02:00..Tue,24May201118:00:00CEST+02:00]我想获得具有重叠时间范围组合的相同数组

  9. javascript - 如何在字符串中获得可能重叠的匹配项 - 2

    我正在寻找一种方法,无论是在Ruby中还是在Javascript中,它都会为我提供字符串中针对正则表达式的所有匹配项,可能是重叠的。假设我有str="abcadc",我想查找出现的a后跟任意数量的字符,然后是c。我要查找的结果是["abc","adc","abcadc"]。关于如何实现此目标的任何想法?str.scan(/a.*c/)会给我["abcadc"],str.scan(/(?=(a.*c))/).flatten会给我["abcadc","adc"]. 最佳答案 defmatching_substrings(string,r

  10. javascript - HighCharts:仅在系列重叠时使用共享工具提示 - 2

    在下面的HighCharts示例中,系列A和B具有相同的数据。只有B的线在图表绘图区域中可见,因为它直接绘制在A上。终端用户不可能知道A在B后面。我们可以在配置对象中设置tooltip.shared=true以在悬停在任何系列上时显示给定x轴点的所有数据值。但是,在我的真实示例中,我在图表上绘制了多达50个系列,这是不合适的。是否可以保持tooltip.shared=false的行为,但是当用户将鼠标悬停在与一个或多个系列重叠的系列上时,显示所有(且仅)工具提示中的重叠系列值?或者是否有任何其他用户友好的方式来指示在给定的x值处有2个以上相同的y值?http://jsfiddle.ne

随机推荐