Tôi đang cố gắng triển khai CollapsingToolbarLayout với NestedScrollView và nó hiển thị TextView trong NestedScrollView ở phía dưới và không cho phép, cuộn hoặc thu gọn Thanh công cụ. Tôi đã nhận được điều này để làm việc với một RecyclerView nhưng không NestedScrollView. Khi tôi xóa app:layout_behavior="@string/appbar_scrolling_view_behavior
Thanh công cụ bị thu hẹp nhưng NestedScrollView không nằm dưới AppBarLayout. Bất kỳ giải pháp hoặc đề xuất nào để sửa lỗi này?CollapsingToolbarLayout và NestedScrollView không hoạt động
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:fitsSystemWindows="true">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Hello"
android:textColor="#000"
android:textSize="16sp"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="134dp"
android:background="@color/primary"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
quả
Thêm 'android: fitsSystemWindows =" true "vào trong CoordinatorLayout và NestedScrollView. Tiếp theo di chuyển nestedScrollview phía trên AppBarLayout. – Psypher
@ ɥʇᴉɾuɐɹ Chỉ cập nhật câu trả lời của tôi với những gì bạn đã hỏi. Vẫn là kết quả tương tự. –
@ ɥʇᴉɾuɐɹ Nếu bạn có một ví dụ làm việc đơn giản về điều này, hãy đăng nó và tôi sẽ kiểm tra nó. –