Ich habe eine Aktivität mit Navigationsschublade und randlosen Fragment (mit Bild in der Oberseite, die hinter transluzenten Systemleiste auf Lollipop erscheinen muss). Während ich eine Übergangslösung hatte, bei der das Fragment aufgeblasen wurde, indem ich einfach <fragment>
in Activities XML-Tag hatte, sah es gut aus.fitsSystemWindows Effekt für Fragmente über FragmentTransaction gegangen
Dann hatte ich <fragment>
mit <FrameLayout>
und führte Fragment Transaktionen zu ersetzen, und jetzt das Fragment hinter der Systemleiste nicht mehr angezeigt wird, trotz fitsSystemWindows
zu true
über alle erforderliche Hierarchie festgelegt ist.
Ich glaube, es könnte einen Unterschied zwischen <fragment>
wird in Activity-Layout vs allein aufgebläht sein. Ich habe gegoogelt und ein paar Lösungen für KitKat gefunden, aber keiner von denen arbeitete für mich (Lollipop).
activity.xml
<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_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/fragment_host"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
</FrameLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"/>
</android.support.v4.widget.DrawerLayout>
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="224dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
...
Es funktionierte, wenn activity.xml diese Art und Weise war:
<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_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment"
android:name="com.actinarium.random.ui.home.HomeCardsFragment"
tools:layout="@layout/fragment_home"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"/>
</android.support.v4.widget.DrawerLayout>
Dies ist die echte Lösung. Vielen Dank! Mit dieser Information habe ich eine Unterklasse von FrameLayout geschrieben, die WindowIssets an ihre Childs weiterleitet, um einen ähnlichen Effekt wie CoordinatorLayout zu erreichen, wie Sie es vorgeschlagen haben. Für alle Interessierten: https://gist.github.com/Pkmmte/d8e983fb9772d2c91688 – Pkmmte
Danke Ian! Ich bin gerade hierher gekommen, um diese Frage mit dem Hinweis auf Ihren gestrigen Beitrag zu beantworten, aber Sie haben dies bereits getan (: – Actine
@Pkmmte, ich kann es immer noch nicht mit FT arbeiten! Gibt es ein Beispielprojekt mit 'WindowInsetsFrameLayout'? Und 2. Frage - ist es kompatibel zu ICS? – WindRider