title: android - bottom behavior child views changes doesn't always work
body: <p>In my activity I have map with markers. When user clicks marker, it shows details about that place with bottom sheet.</p>
  
  <p>When views filled with data about place for the first time, it works properly. But after hiding bottomsheet, then showing it after click again it doesn't work properly:
  TextView saves old height (<code>view.invalidate()</code> doesn't work).
  <code>viewGroup.addView</code> method doesn't work (calling <code>viewGroup.removeAllViews()</code> before adding, but it keeps old height and adding views doesn't work).</p>
  
  <p>But when I change views data without hiding/showing bottomSheet, all things work properly. Like changing for the first time.</p>
  
  <p>I saw other other weird behaviors too, while debugging: I had linearLayout which had 4 relativeLayouts (with textView and imageView inside). When I changed visibility(gone/visible) of one/two they would overlap to each other, even though linearLayout had vertical orientation. But not always, just like above: first time works okay, other times if I change views when bottomSheet is not visible doesn't work properly (as described), but when bottomBehavior is visible and if I change views it works okay (like first time).</p>
  
  <p>If I'm not mistaken, it's because of bottomsheet. Becuause, I didn't see like this behavior of views on Android before.</p>
  
  <p>My code:</p>
  
  <pre><code>mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheetView);
      mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
          @Override
          public void onStateChanged(@NonNull View bottomSheet, int newState) {
              switch (newState) {
                  case BottomSheetBehavior.STATE_HIDDEN:
                      hidePlaceDetails();
                      break;
              }
          }
  
          @Override
          public void onSlide(@NonNull View bottomSheet, float slideOffset) {
          }
      });
  
  /**
   * Show bottom sheet with given place details and start load route
   *
   * @param place the place
   */
  private void showPlaceDetails(Place place) {
      placeTitleView.setText(place.getTitle());
      placeCategoryView.setText(place.getParentTitle());
  
      placeInfoGroup.removeAllViews();
      addPlaceInfo(R.drawable.ic_info, place.getDescription(), null);
      addPlaceInfo(R.drawable.ic_place, place.getAddress(), null);
      addPlaceInfo(R.drawable.ic_phone, place.getPhoneNumbers(), null);
      addPlaceInfo(R.drawable.ic_language, place.getWebsite(), null);
  
      Photo photo = place.getPhoto();
      if (U.isEmpty(photo.getImagePath())) {
          U.hideView(placePhotoView);
      } else {
          U.showView(placePhotoView);
          int proportionalHeight = U.calculateProportionalHeight(
              screenSize[0] /*screenWidth*/,
              photo.getWidth(),
              photo.getHeight(),
              800 /*maxHeight*/);
          FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT,
              proportionalHeight
          );
  
          placePhotoView.setLayoutParams(layoutParams);
          ImageUtils.networkImage(this, photo, placePhotoView, null, U.imagePlaceholder());
      }
  
      U.view(placeDistanceProgressView, true); //showView
      U.view(placeDistanceView, false); //hideView
      if (mMap.getMyLocation() != null) {
          Waypoint myLocation = new Waypoint(mMap.getMyLocation().getLongitude(), mMap.getMyLocation().getLatitude());
          Waypoint destination = new Waypoint(place.getPosition().getLongitude(), place.getPosition().getLatitude());
  
          getAndDrawRoute(place, myLocation, destination);
      }
  
      int thirdScreen = screenSize[1] / 3;
      mMap.setPadding(0, 0, 0, halfScreen);
      isShowingPlaceDetails = true;
      mBottomSheetBehavior.setPeekHeight(halfScreen);
      mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
  }
  
  /**
   * Hide bottom sheet and add markers
   */
  private void hidePlaceDetails() {
      mMap.setPadding(0, 0, 0, 0);
      mBottomSheetBehavior.setPeekHeight(0);
      mBottomSheetBehavior.setHideable(true);
      mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
      addMarkers();
      isShowingPlaceDetails = false;
  }
  
  /**
   * @param icon            icon res
   * @param title           title
   * @param onClickListener nullable
   */
  private void addPlaceInfo(
      @DrawableRes int icon, String title, @Nullable View.OnClickListener onClickListener) {
      View root = LayoutInflater.from(this).inflate(R.layout.layout_map_bottom_sheet_row, null);
      ImageView iconView = ButterKnife.findById(root, R.id.place_icon);
      TextView titleView = ButterKnife.findById(root, R.id.place_title);
      iconView.setImageResource(icon);
      titleView.setText(U.notEmpty(title) ? title : Html.fromHtml(String.format("&lt;i&gt;%s&lt;/i&gt;", "None")));
  
      if (onClickListener != null) {
          root.setOnClickListener(onClickListener);
      }
      placeInfoGroup.addView(root);
  }
  </code></pre>
  
  <p>activity*.xml</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout
  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:id="@+id/drawer"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:fitsSystemWindows="true"&gt;
  
  &lt;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:orientation="vertical"&gt;
  
      &lt;include layout="@layout/toolbar_appbar"/&gt;
  
      &lt;RelativeLayout
          android:id="@+id/content"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;
  
          ...
      &lt;/RelativeLayout&gt;
  
      &lt;android.support.v4.widget.NestedScrollView
          android:id="@+id/bottomSheet"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          android:background="@android:color/white"
          android:elevation="4dp"
          app:behavior_peekHeight="0dp"
          app:layout_behavior="android.support.design.widget.BottomSheetBehavior"&gt;
  
          &lt;include layout="@layout/layout_map_bottom_sheet"/&gt;
  
      &lt;/android.support.v4.widget.NestedScrollView&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  
  ...
  </code></pre>
  
  <p></p>
  
  <p>layout_map_bottom_sheet.xml</p>
  
  <pre><code>&lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@android:color/white"
  android:orientation="vertical"
  android:paddingTop="@dimen/content.margin"&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:paddingLeft="@dimen/content.padding.big"
      android:paddingStart="@dimen/content.padding.big"
      android:paddingRight="@dimen/content.padding"
      android:paddingEnd="@dimen/content.padding"&gt;
  
      &lt;TextView
          android:id="@+id/place.title"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:lineSpacingExtra="@dimen/text.line.space"
          android:textColor="@color/text.color"
          android:textSize="@dimen/text.xlarge"
          tools:text="@string/lorem.place.title"/&gt;
  
      &lt;TextView
          android:id="@+id/place.category"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:lineSpacingExtra="@dimen/text.line.space"
          android:paddingBottom="@dimen/content.padding.small"
          android:paddingTop="@dimen/content.padding.small"
          android:textSize="@dimen/text.medium"
          android:textColor="@color/text.secondary.color"
          tools:text="@string/lorem.short"/&gt;
  
      &lt;include layout="@layout/divider"/&gt;
  
      &lt;TextView
          android:id="@+id/place.distance"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:paddingBottom="@dimen/content.padding.small"
          android:paddingTop="@dimen/content.padding.small"
          android:textColor="?attr/colorPrimary"
          android:visibility="gone"
          tools:text="@string/lorem.place.distance"/&gt;
  
      &lt;ProgressBar
          android:id="@+id/place.distance.progress"
          android:layout_width="20dp"
          android:layout_height="20dp"
          android:layout_marginTop="@dimen/content.padding.small"
          android:layout_marginBottom="@dimen/content.padding.small"/&gt;
  
      &lt;include layout="@layout/divider"/&gt;
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:id="@+id/place.infos"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"&gt;
  &lt;/LinearLayout&gt;
  
  &lt;FrameLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;ImageView
          android:id="@+id/place.photo"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:scaleType="centerCrop"
          tools:src="@drawable/sample"/&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>Screenrecord: <a href="https://drive.google.com/file/d/0B5up2CgQawSDbUZtQ2h1VDBWbms/view?usp=drivesdk" rel="nofollow">https://drive.google.com/file/d/0B5up2CgQawSDbUZtQ2h1VDBWbms/view?usp=drivesdk</a></p>
  
  <p>It was hard for me explain this, but the issue drove me mad for a couple days. I really appreciate any help you can provide!</p>