Tôi đang cố gắng tạo một CollapsingToolbarLayout
và bên dưới nó một listview, khi listview được cuộn thanh công cụ sẽ sụp đổ, nhưng nó không hoạt động khi cuộn thanh công cụ không sụp đổ.CollapsingToolbarLayout không hoạt động (thu gọn) khi cuộn
sử dụng hướng dẫn này: http://android-developers.blogspot.in/2015_05_01_archive.html
Lưu ý: Các FrameLayout chứa listview
<LinearLayout 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="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="192dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbara"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Mã framelayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ranjithnair02.com.supporttest.BlankFragment">
<ListView
android:id="@+id/rcyv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:src="@android:drawable/ic_search_category_default"
app:borderWidth="0dp"
app:elevation="5dp"
app:rippleColor="@color/wallet_highlighted_text_holo_light" />
</RelativeLayout>
Hãy thử thay thế các gốc 'LinearLayout' với 'android.support.design.widget.CoordinatorLayout'. –