2016-07-21 3 views
1

에서 GONE 상태에서 VISIBLE을 설정 한 후 TextView를 사용하여 LinarLayout을 GONE 상태에서 VISIBLE로 "롤오버"애니메이션으로 표시하려했습니다. 이 레이아웃에는 TextView가 있습니다. 모든 작업이 잘된 것처럼 보이지만 애니메이션 후에 TextView가 표시되지 않습니다. 내가 뭘 잘못 했니?애니메이션

 <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:visibility="gone" 
      android:id="@+id/ll_info"> 
      <TextView 
       android:id="@+id/bayer_note" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="20dp" 
       android:layout_marginRight="20dp" 
       android:layout_marginTop="10dp" 
       android:layout_marginBottom="10dp" 
       android:text="@string/buyer_note"/> 
      <RelativeLayout 
       android:id="@+id/button_continue" 
       android:layout_width="match_parent" 
       android:layout_height="54dp" 
       android:layout_centerHorizontal="true" 
       android:layout_marginLeft="@dimen/activity_horizontal_margin" 
       android:layout_marginRight="@dimen/activity_horizontal_margin" 
       android:background="@drawable/button_register" 
       android:drawableEnd="@drawable/ic_arrow_forward_white_24dp"> 

       <TextView 
        android:id="@+id/btn_cont_caption" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:text="Войти" 
        android:textColor="@android:color/white" 
        android:textSize="20sp" 
        android:fontFamily="fonts/SF-UI-Display-Regular.ttf" 
        android:layout_centerInParent="true" /> 

       <ImageView 
        android:layout_width="25dp" 
        android:layout_height="25dp" 
        android:id="@+id/imageView" 
        android:layout_centerVertical="true" 
        android:layout_alignParentEnd="false" 
        android:src="@drawable/ic_door" 
        android:layout_toRightOf="@+id/btn_cont_caption" 
        android:layout_marginLeft="10dp" 
        android:scaleType="fitCenter" /> 
      </RelativeLayout> 
     </LinearLayout> 

애니메이션 코드 :

final LinearLayout ll_info = (LinearLayout)findViewById(R.id.ll_info); 

     class scaleAnimation extends Animation { 
        public LinearLayout ll; 
        public int newHeight; 

        public void scaleTopHeight(int height) 
        { 
         newHeight = height; 
        } 

        public void setLayout(LinearLayout layout) { 
         ll = layout; 
        } 
       } 

       final LinearLayout ll_info = (LinearLayout)findViewById(R.id.ll_info); 

       scaleAnimation h = new scaleAnimation() { 
        @Override 
        protected void applyTransformation(float interpolatedTime, Transformation t) { 
         ll.getLayoutParams().height = interpolatedTime == 1 
           ? LinearLayout.LayoutParams.WRAP_CONTENT 
           : (int)(newHeight * interpolatedTime); 
         ll.requestLayout(); 
        } 
       }; 
       h.setDuration(300); 
       h.setLayout(ll_info); 
     ll_info.setVisibility(View.VISIBLE); 
       ll_info.measure(View.MeasureSpec.makeMeasureSpec(((LinearLayout)ll_info.getParent()).getWidth(), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(((LinearLayout)ll_info.getParent()).getHeight(), View.MeasureSpec.AT_MOST)); 
       h.scaleTopHeight(ll_info.getMeasuredHeight()); 
     ll_info.getLayoutParams().height=1; 
       ll_info.startAnimation(h); 
+0

텍스트 뷰의 textColor가 도움이 될 수 있다면 변경하십시오. – Drv

+0

@Drv, 애니메이션 TextView가 존재하지 않는 경우 및이 TextView 레이아웃의 높이가 작은 LinearLayout. 나는 텍스트 색상이 아닌 이유를 생각합니다 ... – user2076491

+0

선형 레이아웃의 높이를 설정하기위한 적절한 코드를 작성해야합니다. – Drv

답변

0
<RelativeLayout 
      android:id="@+id/button_continue" 
      android:layout_width="match_parent" 
      android:layout_height="54dp" 

      **android:layout_centerHorizontal="true"** ///// 

난이

  android:layout_marginLeft="@dimen/activity_horizontal_margin" 
      android:layout_marginRight="@dimen/activity_horizontal_margin" 
      android:background="@drawable/button_register" 
      android:drawableEnd="@drawable/ic_arrow_forward_white_24dp"> 

      <TextView 
       android:id="@+id/btn_cont_caption" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:text="Войти" 
       android:textColor="@android:color/white" 
       android:textSize="20sp" 
       android:fontFamily="fonts/SF-UI-Display-Regular.ttf" 
       android:layout_centerInParent="true" /> 

      <ImageView 
       android:layout_width="25dp" 
       android:layout_height="25dp" 
       android:id="@+id/imageView" 
       android:layout_centerVertical="true" 
       android:layout_alignParentEnd="false" 
       android:src="@drawable/ic_door" 
       android:layout_toRightOf="@+id/btn_cont_caption" 
       android:layout_marginLeft="10dp" 
       android:scaleType="fitCenter" /> 
     </RelativeLayout> 

께 t 삭제 hink 이것은 XML 파일 문제입니다. center_horizontal에있는 relativelayout 및 모든 하위 항목은 parent.so의 가운데에 있습니다. textview는 이미지 뷰를 숨 깁니다. 그것을 시도하고 알려주세요.

+0

죄송합니다,이 텍스트보기가 보이지 않습니다. id.buyer_note가 표시되지 않습니다. 그러나 Visibly GONE을 설정하지 않으면 활동 시작 후 모든보기의 크기와 가시성이 정확합니다. 하지만 버튼 클릭만으로 ll_info를 보여줘야합니다. 그리고 Desing time Visibility가 GONE으로 바뀌고 런타임시 ll_info 레이아웃이 보이지만 시각적으로 보이게하려면 TextView id.buyer_info가 필요합니다. – user2076491