title: Android: Shared Element Transition with Fragments
body: <p>I'm working on a project where I need a transition between fragments using shared elements. I've tried nearly everything but the transition effect isn't working.</p>
  
  <p>I have an activity called TimelineActivity and I have 2 fragments, a ListFragment that is dynamically added to the TimelineActivity, and a DetailFragment.</p>
  
  <p>Whenever I click on an item in the ListView in the ListFragment, the fragment is being replaced by the DetailFragment. </p>
  
  <pre><code>@Override
  public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
      DetailFragment fragment = DetailFragment.newInstance();
  
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {
          fragment.setSharedElementEnterTransition(new ChangeBounds().setDuration(2000));
          fragment.setEnterTransition(new ChangeBounds().setDuration(2000));
          setExitTransition(new ChangeBounds().setDuration(2000));
          fragment.setSharedElementReturnTransition(new ChangeBounds().setDuration(2000));
      }
  
      FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
  
      fragment.setAllowEnterTransitionOverlap(true);
      fragment.setAllowReturnTransitionOverlap(true);
  
      ft.replace(R.id.timeline_container, fragment);
      ft.addSharedElement(view.findViewById(R.id.transition), "selectClientTransition");
      ft.addToBackStack(null);
  
      // Start the animated transition.
      ft.commit();
  }
  </code></pre>
  
  <p>In my listview_row.xml which is the layout for the listview I have:</p>
  
  <pre><code>   &lt;LinearLayout
     android:id="@+id/transition"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="#FFF"
     android:orientation="vertical"
     android:padding="10dp"
     android:transitionName="selectClientTransition"&gt;
     &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and in my fragment_detail.xml I have the following:</p>
  
  <pre><code>&lt;LinearLayout
                  android:id="@+id/transition"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:background="#FFF"
                  android:orientation="vertical"
                  android:padding="10dp"
                  android:transitionName="selectClientTransition"
                  android:weightSum="12"&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I added this to my AppTheme</p>
  
  <pre><code>&lt;item name="android:windowContentTransitions"&gt;true&lt;/item&gt;
  </code></pre>
  
  <p>Just to be clear, the fragments are replaced, that's working fine, but without a changebounds effect. I'm really stuck here so anything is welcome.</p>
  
  <p>Thanks in advance</p>