我正在使用android支持設計'com.android.support:design:22.2.1'我的問題是,當滾動沒有內容時,摺疊工具欄仍然會啓用摺疊操作。如果滾動中沒有內容,我需要刪除視圖的摺疊。如何禁用CollapsingToolbar的摺疊滾動時沒有內容?
我的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.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:background="@android:color/white"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<fragment
android:id="@+id/pawfile_header"
android:name="com.lightbulb.pawesome.fragments.PawfileHeaderFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<fragment
android:id="@+id/pawfile_timeline"
android:name="com.lightbulb.pawesome.user_timeline.PawesomeUserTimelineFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
UDPATE問題:
我與禁用和啓用視圖的摺疊完成。我用這行代碼以禁用摺疊:
AppBarLayout.LayoutParams appbarParams = (AppBarLayout.LayoutParams) collapsingToolbar.getLayoutParams();
appbarParams.setScrollFlags(0);
collapsingToolbar.setLayoutParams(p);
的問題是,所述appbar是力有scrollflags的高度被設置爲0我嘗試使用appbar.setElevation(0),但它沒有效果。我怎樣才能從我的appbar刪除海拔?
應用:layout_scrollFlags = 「無」 .Will這項工作? – rKrishna
如何以編程方式執行 –