android - SetFitsSystemWindow programmatically doesn't work as expected -


i'm trying work different appbarlayouts in 1 activity.
when fragment loaded, can call "toolbarmanager", handles replacing of active toolbar (namely appbarlayout). of these toolbars (using collapsingtoolbarlayout) want them draw behind statusbar.
works fine when setting "fitssystemwindow" true in xml. when using toolbar layout_scrollflags="scroll", toolbar title displayed behind statusbar.

to avoid this, want disable "fitssystemwindow" when loading such toolbar using setfitssystemwindow(false).

disabling works fine, when re-enabling setfitssystemwindow(true) using collapsingtoolbarlayout, statusbar colored , toolbar placed below statusbar padding in size of statusbar on top.

image: drawn below statusbar instead of behind

when don't use setfitssystemwindow(true) , set true in xml layout, display of collapsingtoolbarlayout fine.

is bug in setfitsystemwindow or method different xml attribute?

here layouts use:

activity:

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:id="@+id/drawer_layout"     android:fitssystemwindows="true"     tools:context=".activities.mainactivity"     style="@style/apptheme">  <android.support.design.widget.coordinatorlayout     android:layout_height="wrap_content"     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:fitssystemwindows="true"     android:id="@+id/coordinator_layout">      <android.support.design.widget.appbarlayout         android:layout_width="match_parent"         android:fitssystemwindows="true"         android:layout_height="wrap_content">      </android.support.design.widget.appbarlayout>       <framelayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:id="@+id/fragment_container"         app:layout_behavior="@string/appbar_scrolling_view_behavior">      </framelayout>      <progressbar         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:indeterminate="true"         android:indeterminateduration="1000"         android:layout_marginbottom="-7dp"         android:id="@+id/loadingbar"         style="@style/widget.appcompat.progressbar.horizontal"         android:layout_gravity="center_horizontal|bottom"         android:gravity="bottom"/> </android.support.design.widget.coordinatorlayout>  <include layout="@layout/include_navigationview" /> 

the appbarlayout replaced every time new fragment loaded.

the following layout toolbar should not draw behind statusbar, toolbar should scroll (leaving tablayout visible)

<android.support.design.widget.appbarlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="wrap_content"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:theme="@style/themeoverlay.appcompat.dark.actionbar"     android:id="@+id/toolbar_discover"     android:fitssystemwindows="true"     android:paddingbottom="0dp">      <android.support.v7.widget.toolbar         xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="match_parent"         android:id="@+id/toolbar"         android:layout_height="?attr/actionbarsize"         xmlns:app="http://schemas.android.com/apk/res-auto"         android:theme="@style/apptheme.toolbar"         app:popuptheme="@style/themeoverlay.appcompat.light"         app:layout_scrollflags="scroll|snap">      </android.support.v7.widget.toolbar>          <android.support.design.widget.tablayout             android:id="@+id/tablayout_discover"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_gravity="bottom"             app:tabmode="fixed"             app:tabgravity="fill" /> </android.support.design.widget.appbarlayout> 

this used work when set fitssystemwindows=false on coordinatorlayout in mainactivity layout. when doing so, following collapsingtoolbar cannot draw behind statusbar.

<android.support.design.widget.appbarlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="wrap_content"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:theme="@style/themeoverlay.appcompat.dark.actionbar"     android:id="@+id/toolbar_account"     android:fitssystemwindows="true"     android:paddingbottom="0dp">      <android.support.design.widget.collapsingtoolbarlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         app:layout_scrollflags="scroll|exituntilcollapsed"         app:contentscrim="?attr/colorprimary"         android:fitssystemwindows="true"         android:id="@+id/collapsingtoolbarlayout">          <imageview             android:layout_width="match_parent"             android:layout_height="250dp"             android:scaletype="centercrop"             android:fitssystemwindows="true"             app:layout_collapsemode="parallax"             android:id="@+id/banner_image"             android:src="@mipmap/img_header"/>          <android.support.v7.widget.toolbar             xmlns:android="http://schemas.android.com/apk/res/android"             android:layout_width="match_parent"             android:id="@+id/toolbar"             android:fitssystemwindows="false"             android:layout_height="?attr/actionbarsize"             xmlns:app="http://schemas.android.com/apk/res-auto"             android:theme="@style/apptheme.toolbar"             app:popuptheme="@style/themeoverlay.appcompat.light"             app:layout_collapsemode="pin">          </android.support.v7.widget.toolbar>     </android.support.design.widget.collapsingtoolbarlayout>  </android.support.design.widget.appbarlayout> 


Comments

Popular posts from this blog

Why does Go error when trying to marshal this JSON? -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

python - Pygame. TypeError: 'pygame.Surface' object is not callable -