android - 如何在scrollview上方使用CollapsingToolbarLayout?

标签 android parallax android-collapsingtoolbarlayout android-nestedscrollview

我想为顶部横幅创建具有视差效果的 View 。

enter image description here

我试过了,但没用:

<?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"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_height="200dp"
    android:layout_width="match_parent">
    <android.support.design.widget.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.v7.widget.AppCompatImageView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="@drawable/main_banner"/>

    </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:background="@color/vahab_background">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@color/vahab_background">

        ...

    </LinearLayout>

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

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

导航栏上方的所有 View 都在 fragment 中膨胀。 我只想在主页选项卡中显示整个视差。

最佳答案

有关 CoordinateLayout 的精彩博客 http://saulmm.github.io/mastering-coordinator

关于android - 如何在scrollview上方使用CollapsingToolbarLayout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43582248/

相关文章:

android - 在 Android Kotlin 中查找日期之间的天数差异

android - 从 firebase 数据库读取值时超时?

android - 如何运行那些 Android SDK 示例应用程序?

javascript - OKVideo 在一页不同部分中显示两个视频

javascript - Google Chrome 不显示视差图像

页脚变为页眉的 jQuery css 视差效果

android - 使用 CollapsingToolbarLayout 时不显示 Viewpager

java - 如何获取 3G 网络的小区 ID?

android - CollapsingToolbarLayout 在 API 26 中的图像下方显示栏

android - 折叠布局行为在垂直 View 寻呼机内无法正常工作