title: How to change the visibility of a child view in onCreateView?
body: <p>I know there are a lot of <code>setVisibility()</code> questions on here but I can't find any about this specific case.  </p>
  
  <p>When I set the visibility in onCreatView():</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
      final View view = inflater.inflate(R.layout.parentfragment, container, false);
  
      View childView = view.findViewById(R.id.child_View)
  
      if(routingIsOn)childView.setVisibility(View.VISIBLE)
      else childView.setVisibility(View.GONE)
      return view;
  }
  </code></pre>
  
  <p>It doesn't change anything.  (I have hard coded the routingIsOn value as both true and false and either way it doesn't affect the view's visibility. </p>
  
  <p>However interestingly if I run the <code>setVisibility()</code> code in a delayed runnable on the main thread it does update the UI as expected.  But this feels really hacky. </p>
  
  <p>So is there a non-hacky way to change the visibility when the fragment is being created?</p>
  
  <p>Here is the parent xml:</p>
  
  <pre><code>&lt;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:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.salesrabbit.android.sales.universal.canvass.map.MapContainerFragment"&gt;
  
  
  
      &lt;FrameLayout
          android:id="@+id/map_container"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;/FrameLayout&gt;
  
      &lt;FrameLayout
          android:id="@+id/route_header_container"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"/&gt;
  
      &lt;FrameLayout
          android:id="@+id/area_container"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;/FrameLayout&gt;
  
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>