Obwohl es viele Fragen zu diesem Thema gibt, schien mir keiner von ihnen zu helfen (ich habe das meiste von dem versucht, was es war, kann es aber immer noch nicht schaffen). Mein Layout ist unten:Wie Symbolleiste in einem Layout mit DrawerLayout, Toolbar und ViewPager mit RecyclerView minimiert?
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:id="@+id/toolbar_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.ogaclejapan.smarttablayout.SmartTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_weight="1"
android:clickable="true"
app:stl_defaultTabTextAllCaps="true"
app:stl_defaultTabTextColor="#000"
app:stl_defaultTabTextHorizontalPadding="0dip"
app:stl_defaultTabTextMinWidth="0dp"
app:stl_defaultTabTextSize="14sp"
app:stl_distributeEvenly="true"
app:stl_drawDecorationAfterTab="true"
app:stl_indicatorColor="@android:color/white"
app:stl_indicatorGravity="bottom"
app:stl_indicatorInFront="false"
app:stl_indicatorInterpolation="smart"
app:stl_indicatorThickness="2dp"
app:stl_overlineThickness="0dp"
app:stl_titleOffset="24dp"
app:stl_underlineThickness="0dp" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/rsc_homepage_drawer_layout_content"
app:menu="@menu/drawer_itens" />
</android.support.v4.widget.DrawerLayout>
Jedes Fragment hat einen RecyclerView. Was ist das Problem? Wenn ich die RecyclerView scrolle, passiert nichts. Wenn ich die Symbolleiste scrolle, verbirgt sie sich und lässt den RecyclerView in seiner ursprünglichen Position zurück. Jede Hilfe wird geschätzt!
UPDATE
Im Folgenden sind alle meine Fragmente:
Fragment 1
<RelativeLayout>
<RelativeLayout>
<android.support.v7.widget.CardView>
<LinearLayout>
<TextView/>
<TextView />
</LinearLayout>
</android.support.v7.widget.CardView>
<com.mikhaellopez.circularimageview.CircularImageView/>
</RelativeLayout>
<LinearLayout>
<TextView />
<TextView />
<TextView />
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.CardView>
<TextView/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.RecyclerView" />
Fragment 2
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null">
....
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="@+id/not_results_found_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:alpha="0.95"
android:elevation="4dip"
android:visibility="gone"
card_view:cardBackgroundColor="@android:color/white"
card_view:cardCornerRadius="5dp"
card_view:cardUseCompatPadding="true">
<TextView
android:id="@+id/not_results_found"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:padding="10dip"
android:text="@string/rsc_search_friends_no_results_founds"
android:textColor="@color/colorPrimaryDark"
android:textSize="@dimen/textH3"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.RecyclerView
android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/not_results_found_wrapper"
android:layout_marginEnd="10dip"
android:layout_marginStart="10dip"
android:layout_marginTop="5dip"
android:overScrollMode="never" />
</RelativeLayout>
</ScrollView>
Fragment 3
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/chats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" />
<android.support.v7.widget.CardView
android:id="@+id/msg_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="30dip"
android:alpha="0.95"
android:elevation="4dip"
card_view:cardBackgroundColor="@android:color/white"
card_view:cardCornerRadius="5dp"
card_view:cardUseCompatPadding="true">
<TextView
android:id="@+id/results_not_found"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:layout_margin="15dip"
android:text="@string/frag_chats_no_chat_use"
android:textAlignment="center"
android:textColor="@color/colorPrimaryDark"
android:textSize="@dimen/textH2"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
</RelativeLayout>
Fragment 4
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<android.support.v7.widget.RecyclerView
android:id="@+id/games"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_wrapper"
android:overScrollMode="never"/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/add_game"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dip"
android:clickable="true"
android:src="@drawable/ic_plus_white_24dp"
app:borderWidth="0dp"
app:elevation="4dp"
app:layout_anchor="@id/games"
app:layout_anchorGravity="bottom|right|end"
fab:fab_colorNormal="@color/colorPrimary"
fab:fab_colorPressed="@color/colorPrimaryDark" />
</android.support.design.widget.CoordinatorLayout>
entfernen 'App: layout_behavior = "@ Zeichenfolge/appbar_scrolling_view_behavior"' 'von ViewPager' und es zu jedem Elternteil Ihres Fragment (geordneten Ansicht von RecyclerView). –
Selbe Sache. Was ich gerade festgestellt habe, ist, dass zwei meiner Fragmente durch Elternkomponente eine ScrollView und ein anderes CoordinatorLayout haben. Ist das ein Problem? –
Ja, die Bildlaufansicht wird das Minimieren der Symbolleiste einschränken. Geben Sie Ihrem RecyclerView also ein lineares oder relatives Layout mit 'app: layout_behavior =" @ string/appbar_scrolling_view_behavior "' oder gar keinem Elternteil und der Recycler-Ansicht mit dem obigen 'layout_behaviour'-Flag. –