我正在使用这段代码:
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 转换到新位置并留在那个地方并正常工作。但事实并非如此。有人可以发现错误并纠正我。或者为相同的问题提供不同的技术?