我有以下佈局:抽屜,主內容視圖具有AppBarLayout,RecyclerView和TextView。當我滾動回收站時,工具欄被正確隱藏。以編程方式顯示滾動隱藏後的工具欄(Android設計庫)
但是,我有一個用例:當回收站中的所有項目都被移除時,我將它的可見性設置爲「不見了」,並顯示一個帶有相應消息的TextView。如果這是在隱藏工具欄的情況下完成的,則用戶不可能再次看到工具欄。
是否有可能以編程方式導致工具欄完全顯示?每當顯示TextView而不是RecyclerView時,我都會這樣做。
這裏是我的佈局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
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"
android:animateLayoutChanges="true">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/test_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<TextView
android:id="@+id/empty_test_list_info_label"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="@dimen/spacing_big"
android:textAppearance="?android:attr/textAppearanceLarge"
android:visibility="gone"/>
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?android:attr/windowBackground"
android:elevation="10dp"/>
</android.support.v4.widget.DrawerLayout>
BTW,出於某種原因,如果我把RecyclerView後AppBarLayour,所有教程似乎表明,它從列表中隱藏的最上方項目。它只在高於它時才能正常工作。
您是否找到了解決方案?我有同樣的問題.. –
@GennadiiSaprykin - 不,我沒有,對不起。我認爲最終我實施了一些不同的方式,但這已經很長時間了,我不知道它是什麼,並從那時起改變了項目。 – wujek