간단한 설정 : RecyclerView
에 각각 TextView
을 포함하는 항목 목록이 표시됩니다. 텍스트보기 중 하나는 여러 줄을 가질 수 있습니다. 처음에는 android:maxLines
이 1로 설정되었습니다. 항목의 클릭 수신기에서 최대 1 줄과 최대 무한대 (전체 내용 표시) 사이를 전환합니다. 그것은 움직이지 않는 것을 제외하고는 잘 동작합니다. 내 뷰 계층 구조에서 다른 레벨에 android:animateLayoutChanges
을 추가하려고했지만 애니메이션은 여전히 사용하지 않았습니다.android : animateLayoutChanges가 TextView의 maxLines를 변경할 때 RecyclerView에서 작동하지 않습니다.
제 생각에 대해 알려주세요.
참고 : 수동 애니메이션을 프로그래밍 할 수 있지만 Android에서이 xml 속성으로 처리하도록합니다. MY 코드
일부 :이
내 목록 항목 레이아웃 : 나는 comments
텍스트 뷰를 확장하고
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:animateLayoutChanges="true"
android:padding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<TextView
android:id="@+id/destination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginEnd="36dp"
android:layout_marginRight="36dp"
android:textStyle="bold"
android:ellipsize="end"
android:maxLines="1"
android:textSize="25sp" />
<ImageButton
android:id="@+id/editButton"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_edit"
android:contentDescription="@string/edit_button_content_descr"
android:background="?attr/selectableItemBackgroundBorderless" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/dateRange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp" />
<Space
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<TextView
android:id="@+id/daysLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:background="@drawable/days_left_background"
android:gravity="end"
android:layout_gravity="end"
android:textColor="@android:color/white"
android:textSize="15sp"
android:textStyle="bold"/>
</LinearLayout>
<TextView
android:id="@+id/comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textSize="15sp"
android:ellipsize="end"
android:maxLines="1" />
</LinearLayout>
</android.support.v7.widget.CardView>
: 여기
rootCard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
comments.setMaxLines((comments.getMaxLines() == 1) ? Integer.MAX_VALUE : 1);
}
});
가있다 Recycler가 포함 된 내 조각의 레이아웃 보기 :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/common_vertical_margin"
android:paddingLeft="@dimen/common_horizontal_margin"
android:paddingRight="@dimen/common_horizontal_margin"
android:paddingTop="@dimen/common_vertical_margin"
xmlns:tools="http://schemas.android.com/tools">
<android.support.v7.widget.RecyclerView
android:id="@+id/tripList"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/list_item_trip" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_add" />
</RelativeLayout>
감사합니다. – frangulyan