title: fitSystemWindows programmatically for status bar transparency
body: <p>My app has one activity that hosts different fragments for each section. I have recently made the status bar translucent by setting <code>fitSystemWindows</code> to <code>true</code>, which has set it to the background colour of the app. This is fine for fragments that have a toolbar, where the colours match, like so:</p>
  <p><img src="https://i.stack.imgur.com/YRwbM.png" alt="enter image description here" /></p>
  <p>However one of my fragments has a photo and a translucent toolbar, so I'd like to have the photo occupy the space of the status bar too, rather than the background colour.</p>
  <p>I believe the solution is to set <code>fitSystemWindows</code> to <code>false</code> for that fragment only, and manually add padding to the translucent toolbar. Doing this programmatically seems to have no effect, what could I be doing wrong?</p>
  <p>Here is my main activity layout:</p>
  <pre><code>&lt;RelativeLayout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:id=&quot;@+id/main_parent_view&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot;
      android:fitsSystemWindows=&quot;true&quot;&gt;
  
  &lt;!-- Container for various fragment layouts, including nav drawer and toolbar --&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>And from within my fragment's onCreateView():</p>
  <pre><code>RelativeLayout daddyLayout = (RelativeLayout)getActivity().findViewById(R.id.main_parent_view);
  daddyLayout.setFitsSystemWindows(false);
  daddyLayout.invalidate();
  </code></pre>
  <p>This seems to have no effect, like so:</p>
  <p><img src="https://i.stack.imgur.com/PpYH7.png" alt="enter image description here" /></p>
  <p>If I set <code>fitSystemWindows</code> to false in the <code>main_parent_view</code>, the status bar padding is gone and it works but obviously <strong>affects every fragment</strong>.</p>