我想用頂部橫幅的視差效果來創建此視圖。如何在滾動視圖上方使用CollapsingToolbarLayout?
我試過,但它不工作:
<?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>
所有導航欄上面的意見片段被誇大。 我只想要在主頁選項卡中的整個視差。在CoordinateLayout http://saulmm.github.io/mastering-coordinator
請發表您的Java代碼也處理CollapsingToolbarLayout。 –
@VinodPattanshetti你會建議一個代碼來正確處理它嗎? 我沒有在java中做任何事情。只是誇大了佈局。 – Mohsen