Ich habe eine Tätigkeit, die eine ViewPager
enthält: Dieser Pager enthältAppBar fitsSystemWindows - innerhalb einer ViewPager
activity.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"/> </FrameLayout>
Die Fragmente - die alle aus demselben Layout erzeugt werden - haben a CoordinatorLayout
und CollapsingToolbarLayout
, um eine kollabierende Image-Back-Titelleiste bereitzustellen:
fragment.xml:
<android.support.design.widget.CoordinatorLayout 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:id="@+id/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.v4.widget.NestedScrollView android:id="@+id/scrollview" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <!-- Content here --> </android.support.v4.widget.NestedScrollView> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="256dp" android:elevation="8dp" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:expandedTitleMarginStart="72dp" android:fitsSystemWindows="true"> <ImageView android:id="@+id/photo" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" app:layout_collapseMode="parallax" android:background="@color/photo_placeholder" android:fitsSystemWindows="true"/> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:layout_width="match_parent" android:layout_height="?actionBarSize" app:layout_collapseMode="pin" android:layout_gravity="bottom"> </android.support.v7.widget.Toolbar> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> </android.support.design.widget.CoordinatorLayout>
Ohne die fitsSystemWindows
Flaggen in der Aktivität Layout, das Bild in dem Fragment zeigt ordnungsgemäß hinter der Systemstatusleiste, während der Text manchmal hinter der Statusleiste zusammenbricht, wenn nach oben gescrollt. Wenn ich die Markierungen einfüge - wie oben gezeigt -, ist das Textproblem gelöst, aber das Bild wird jetzt in der Statusleiste abgeschnitten. Halten Sie den kollabierenden Symbolleisten-Code im Fragment, gibt es eine Möglichkeit, den Inhalt des Fragments an das Systemfenster anzupassen?
Ohne fitsSystemWindows
der Tätigkeit (bevorzugte Verhalten):
Mit fitsSystemWindows
der Tätigkeit:
Können Sie ein Bild des Problems zeigen? – GPack
@GPack: Bilder hinzugefügt. – RedBassett
Und was ist der Text, der manchmal hinter der Statusleiste zusammenbricht, der Titel der Toolbar vielleicht? – GPack