2011-02-12 7 views
0

내 레이아웃은 글고 및 웹보기의 서브 클래스로 구성Android :보기 애니 메이팅?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 

<EditText android:id="@+id/addressbar" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="@android:drawable/editbox_background" 
       /> 

<com.android.ibrowser.myWebView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/browser" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 

/> 

</LinearLayout> 

언제 이동과 사라, 그래서 웹보기에 onScrollChanged 메소드를 오버라이드 (override) 할 수 글고 치기를하고 싶은 웹보기 아래로 사용자가 스크롤 :

protected void onScrollChanged (int l, int t, int oldl, int oldt){ 

    super.onScrollChanged(l, t, oldl, oldt); 


    if (addressBar.getBottom() > 0){ 

     AnimationSet animation = new AnimationSet(true); 
     TranslateAnimation translateAnimation = new TranslateAnimation(0, 0 
       , -t + oldt, -t + oldt); 
     translateAnimation.setDuration(100); 
     animation.addAnimation(translateAnimation); 
     animation.setFillAfter(true); 

     animation.setAnimationListener(new AnimationListener() { 

      @Override 
      public void onAnimationEnd(Animation arg0) { 
       addressBar.clearAnimation(); 
       // Change view to state B by modifying its layout params and scroll 
      } 



      @Override 
      public void onAnimationRepeat(Animation animation) { 
       // TODO Auto-generated method stub 

      } 

      @Override 
      public void onAnimationStart(Animation animation) { 
       // TODO Auto-generated method stub 

      } 
     }); 
     addressBar.startAnimation(animation); 
    } 

} 

그러나 효과는 EditText가 맨 위로 이동하지만 즉시 원래 위치로 돌아갑니다. 어떻게 생각해?

답변

0

translateAnimation.setFillAfter(true)을 추가하십시오.

translateAnimation.setFillEnabled(true); 

translateAnimation.setFillAfter(true); 

하기 전에 그리고 그것은 작동합니다

+0

아무 것도 바뀌지 않았습니다 ... – Alex1987

2

당신은 전화를해야합니다.