我正在尝试更改Android中的布局,如幻灯片转换动画。这该怎么做?我有四个布局,这四个必须使用幻灯片转换动画等按钮进行更改。在此先感谢。
答案 0 :(得分:0)
在这里你应该帮助。你可以将viewFilpper与slide andimaiton一起使用
这是一个示例链接 using-view-flipper-in-android
而不是示例中的那些textview,您可以放置4个布局。
答案 1 :(得分:0)
你可以用两种方式做到这一点,
1)在manifest.XML中声明所有4个活动并使用Intent你可以使用Intent实现
见这个,
http://marakana.com/forums/android/examples/65.html
2)你也可以使用Viewflipper,因为你有4个视图你可以使用flipper.setDisplayChild()。看到这里
ViewFlipper flipper;
private Animation inFromTopAnimation() {
Animation inFromTop = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
inFromTop.setDuration(1000);
inFromTop.setInterpolator(new AccelerateInterpolator());
return inFromTop;
}
private Animation outToBottomAnimation() {
Animation outtoBottom = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, +1.0f
);
outtoBottom.setDuration(1000);
outtoBottom.setInterpolator(new AccelerateInterpolator());
return outtoBottom;
}
private Animation outToTopAnimation() {
Animation inFromTop = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
inFromTop.setDuration(1000);
inFromTop.setInterpolator(new AccelerateInterpolator());
return inFromTop;
}
private Animation outFromBottomAnimation() {
Animation outFromBottom = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f
);
outFromBottom.setDuration(1000);
outFromBottom.setInterpolator(new AccelerateInterpolator());
return outFromBottom;
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
flipper = (ViewFlipper) findViewById(R.id.flipper);
Button button1 = (Button) findViewById(R.id.button1);
Button button2 = (Button) findViewById(R.id.flipback);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(inFromTopAnimation());
flipper.setOutAnimation(outToBottomAnimation());
flipper.showNext();
}
});
button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(outToTopAnimation());
flipper.setOutAnimation(outFromBottomAnimation());
flipper.showPrevious();
}
});