我想为顶部横幅创建具有视差效果的 View 。
我试过了,但没用:
<?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/