setFillAfter不工作?

时间:2012-05-22 14:15:24

标签: android animation translate-animation

我正在使用此代码:

  public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

 final   LinearLayout answerLayout=(LinearLayout)findViewById(R.id.answerlayout);

    Button slideAnswer=(Button)findViewById(R.id.answerslide);
    slideAnswer.setOnClickListener(new View.OnClickListener() {

    @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

                TranslateAnimation slide = new TranslateAnimation(0,-400, 0,0 );   
                slide.setDuration(1000);   
                slide.setFillAfter(true);   
                slide.setFillEnabled(true);
                answerLayout.startAnimation(slide);  

        }
    });
}

我只是希望answerLayout转换到新位置并留在那个地方并正常工作。但事实并非如此。有人可以发现错误并纠正我。或者给出不同的技术吗?

0 个答案:

没有答案