2013-10-25 2 views
1

nhaarman의 ListViewAnimations (http://nhaarman.github.io/ListViewAnimations/)를 사용하여 각 행에 상위 뷰가 하나씩 있고 하위 뷰 하나가 상위 뷰를 클릭 할 때 확장되는 확장 가능한 목록 뷰를 구현하고 있습니다. . 하위 행에는 다양한 높이의 텍스트보기가 있습니다. 그러나 목록보기가 렌더링되고 하위보기를 클릭하여 확장하면 모든 내용을 표시 할 정도로 확장되지 않습니다. 내가 처음에 fill_parent로 설정 텍스트 뷰의 layout_height했지만, wrap_content 그들을 통해 변경ListViewAnimations 확장 가능 목록의 하위 요소가 내용에 맞게 확장되지 않습니다.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/list_item_child" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@android:color/white" 
    android:paddingBottom="20dp" 
    android:paddingLeft="20dp" 
    android:paddingRight="20dp" > 

    <ImageView 
     android:id="@+id/listItemArrow" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:contentDescription="@null" /> 

    <RelativeLayout 
     android:id="@+id/listItemInfoContainer" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:id="@+id/listItemTitle" 
      style="@style/ScentTitle" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="20dp" /> 

     <TextView 
      android:id="@+id/listItemDetails" 
      style="@style/itemDetails" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/listItemTitle" /> 

     <Button 
      android:id="@+id/listItemShopNowButton" 
      style="@style/itemButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/listItemDetails" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="10dp" 
      android:paddingLeft="30dp" 
      android:paddingRight="30dp" 
      android:text="@string/shop_now" /> 

    </RelativeLayout> 

</RelativeLayout> 

:

는이처럼 내 아이 뷰의 레이아웃이 모습입니다. 그것은 그것도 고칠 것 같지 않았다. 비슷한 문제가있는 사람이 있습니까?

Screenshot

답변

1

당신이 시도 할 수 있습니다, 당신은 ListViewAnimations 라이브러리에 ExpandableListItemAdapter.java을 수정해야합니다.

는 전체 확장 레이아웃을 래핑 있도록이 함께 animateExpanding() 메소드를 교체하십시오 :

public static void animateExpanding(final View view) { 

     /* 
     * Set this view to invisible so that the size can be measured. If it's set to View.VISIBLE here 
     * the maximized layout appears to flicker in before animating. 
     */ 
     view.setVisibility(View.INVISIBLE); 

     view.post(new Runnable() { 

      @Override 
      public void run() { 

       /* 
       * Do view.getWidth in a view.post thread or else the first view.getWidth will always be 0. 
       * 
       * The width MeasureSpec cannot be set to UNSPECIFIED here or else the height of wrapped 
       * textViews gets calculated as if it's a single infinitely long line. 
       */ 
       int widthSpec = View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.AT_MOST); 
       int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); 
       view.measure(widthSpec, heightSpec); 

       ValueAnimator animator = createHeightAnimator(view, 0, view.getMeasuredHeight()); 
       animator.start(); 
       view.setVisibility(View.VISIBLE); 
      } 
     }); 

    } 

문제는 원래 한 줄의 경우로 계산되는 포장 텍스트 textViews에 자리 잡고 있습니다. 레이아웃에 해당 배치 텍스트가 없으면 라이브러리가 정상적으로 작동합니다.

Niek Haarman이 픽스를 다른 고급 솔루션으로 업데이트하는 경우를 확인하십시오. https://github.com/nhaarman/ListViewAnimations/issues/61을 확인하십시오.

+0

이것은 작동합니다. 그러나이 솔루션을 사용하면 애니메이션이 깜박입니다. – user1689757

+0

2.6.0 태그에서 체크 아웃하면 버그가 수정되었습니다. 따라서 더 이상이 문제가 발생하지 않습니다. – jesobremonte

관련 문제