title: Hide Activity while loading until all content is loaded
body: <p>I would like to know if it is possible to hide and activity and his associated components until content is loaded. For example I retrieve an image from an url into an imageview, and there is always a delay until the image shows up. I want to hide it from the user with fading out the whole activity and just show a progressbar for example.</p>
  
  <p>Can somebody please guide me on this topic?</p>
  
  <p>Thanks!</p>
  
  <p>I set the visibility in layout to invisible, like this:</p>
  
  <pre><code> &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:visibility="invisible" &gt;
  ...
   &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Then I have a fragment class, following the onCreateView method:</p>
  
  <pre><code>public class ProfileFragment extends Fragment implements OnClickListener {
  
  @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
  
          profile_view = inflater.inflate(R.layout.profile_fragment_layout,
                  container, false);
  
  
          return profile_view;
  
      }
  </code></pre>
  
  <p>After the AsynchTask is done, I try to set the visibility to visible, but the layout still is invisible:</p>
  
  <pre><code>@Override
          protected void onPostExecute(JSONObject json) {
              /**
               * Checks for success message.
               **/
              try {
                  if (json.getString(KEY_SUCCESS) != null) {
  
                      String res = json.getString(KEY_SUCCESS);
  
                      String red = json.getString(KEY_ERROR);
  
                      if (Integer.parseInt(res) == 1) {
  
                          JSONObject json_user = json.getJSONObject("user");
  
                          image_url = json_user.getString(KEY_AVATAR_PATH);
  
                          // ImageLoader class instance
                          ImageLoader imgLoader = new ImageLoader(getActivity());
  
                          imgLoader.DisplayImage(image_url, image_);
  
  
                          profile_view.setVisibility(View.VISIBLE);
  }
  </code></pre>