Reduzieren Sie die Symbolleiste nicht, wenn RecyclerView auf den Bildschirm passt.
Ich habe eine App mit @ erstellAndroid Design Library, mit einer Symbolleiste und einem TabLayout.
Tatsächlich sind 2 Registerkarten vorhanden, beide mit 2 RecyclerView, die die Symbolleiste beim Scrollen automatisch reduzieren.
Meine Frage ist: Kann ich das Ausblenden der Symbolleiste deaktivieren, wenn RecyclerView nur wenige Elemente enthält und vollständig auf den Bildschirm passt (wie in TAB 2)?
Ich habe viele Beispiele wie @ geseh CheeseSquare, erstellt von einem Google-Mitarbeiter, bei dem das Problem weiterhin besteht: Auch wenn die RecyclerView nur 1 Element enthält, wird die Symbolleiste beim Blättern nicht ausgeblendet.
Ich denke, ich kann nur herausfinden, ob das erste Element der RecyclerView auf dem Bildschirm sichtbar ist, und wenn ja, deaktivieren Sie das Ausblenden der Symbolleiste. Ersteres ist einfach zu implementieren, was ist mit Letzterem?
Dies ist mein Layout:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
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"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/glucosio_pink"
app:tabSelectedTextColor="@android:color/white"
app:tabIndicatorColor="@color/glucosio_accent"
app:tabTextColor="#80ffffff"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/main_fab"
android:layout_margin="16dp"
android:onClick="onFabClicked"
app:backgroundTint="@color/glucosio_accent"
android:src="@drawable/ic_add_black_24dp"
android:layout_gravity="bottom|right"
/>
</android.support.design.widget.CoordinatorLayout>