【问题标题】:Android Collapsing Toolbar: the header image overlap the content at the firstAndroid Collapsing Toolbar:标题图片与内容重叠
【发布时间】:2015-12-13 11:53:46
【问题描述】:

我正在使用折叠工具栏为我的详细信息活动构建视差标题图像。

除了我第一次打开活动外,它运行良好。那时,标题图像默认展开,但它与内容的一部分(嵌套滚动视图)重叠。

我想要的是嵌套滚动视图从标题图像的末尾开始,而不是从屏幕顶部开始,然后它不会被视差图像重叠。

我现在没有任何理想。你以前面对过吗?请帮我一把!

下面是xml代码。

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/grey_100"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        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="?attr/colorPrimary"
            app:expandedTitleMarginBottom="32dp"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/img_cover"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:transitionName="cover"
                android:src="@drawable/room"
                app:layout_collapseMode="parallax" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/tb_toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="5dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

【问题讨论】:

  • 你发现问题了吗???
  • @hushed_voice 抱歉,我不记得了。时间太长了:(

标签: android android-collapsingtoolbarlayout


【解决方案1】:

试试这个解决方案,它解决了我的问题

<ImageView ...
        android:focusableInTouchMode="true"/>

如果您在 NestedScrollView 中使用回收站视图,则设置`

<android.support.v7.widget.RecyclerView ...
        android:nestedScrollingEnabled="false"/>

【讨论】:

  • 为我工作的recycleview
猜你喜欢
  • 1970-01-01
  • 2015-10-06
  • 2020-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-03
相关资源
最近更新 更多