2016-09-12 3 views
0

Я пытаюсь сделать то же анимацию Google: https://vid.me/9Wli«Развернуть более» с анимацией

Быстрое объяснение о моем приложении:

На вершине у меня есть AppBar, под ним LinearLayout включая кнопку для увеличения информации и ниже этого LinearLayout У меня есть RecyclerView.

На данный момент, когда я нажимаю кнопку «expand more», я просто показываю некоторые элементы с .setVisibility (View.VISIBLE), поэтому у меня нет анимации.

Вот мой реальный код XML:

<LinearLayout 
    android:id="@+id/expandable_zone" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:orientation="vertical" 
    android:visibility="gone"> 

    <LinearLayout 
     android:id="@+id/1" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="@dimen/activity_horizontal_margin" 
      android:layout_width="wrap_content" 
      android:text="@string/expandable_1" 
      android:textColor="@color/secondaryTextDark" 
      android:textSize="13dp" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/bottom_expandable_zone" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" 
     android:orientation="vertical"> 

     <TextView 
      android:animateLayoutChanges="true" 
      android:id="@+id/expand_more" 
      android:layout_gravity="center_horizontal" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="11sp" 
      android:layout_marginTop="11sp" 
      android:layout_width="wrap_content" 
      android:text="@string/expand_more" 
      android:textColor="@color/secondaryTextDark" /> 

     <ImageButton 
      android:background="@drawable/circle_shape" 
      android:id="@+id/expand_less" 
      android:layout_gravity="center_horizontal" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="11sp" 
      android:layout_marginTop="10sp" 
      android:layout_width="wrap_content" 
      android:src="@drawable/ic_check_grey600_24dp" 
      android:visibility="gone" /> 
    </LinearLayout> 
</LinearLayout> 

Может кто-нибудь дать мне самое лучшее решение, чтобы сделать это?

ответ

1

android:animateLayoutChanges="true"
установить его на LinearLayout android:id="@+id/bottom_expandable_zone"

, если это не поможет и нужно к поиску на StackOverflow, как оживить представление и реализовать его на свой android:id="@+id/bottom_expandable_zone"