您可以根据需要使用样式:
<style name="noAnimTheme" parent="android:Theme">
<item name="android:windowAnimationStyle">@null</item>
</style>
并为您的活动设置它们:
<activity android:name=".ui.ArticlesActivity" android:theme="@style/noAnimTheme">
</activity>
如果你是这个意思,请告诉我...
感谢@Santosh https://stackoverflow.com/a/9312957/3180983
当我构建我的应用程序时,我只使用了一项活动。在活动中有 4 个自定义视图。每个自定义视图都代表另一个“活动”,它不是真正的活动......我玩的自定义视图很少,所以每个都是另一个窗口......
这是带有动画的代码(*** 如果您不想要动画,请跳过此代码到下面的下一个 goToRegistrationPage()。):
//This code change the view so that the register form will appear. instead of changing activity with animation.
public void goToRegistrationPage()
{
Animation animationRightX1 = AnimationUtils.loadAnimation(this, R.anim.translate_right_x1);
//animationRightX1.
Animation animationRightX2 = AnimationUtils.loadAnimation(this, R.anim.translate_right_x2);
Animation animationRightX3 = AnimationUtils.loadAnimation(this, R.anim.translate_right_x3);
final int width = this.getWindowManager().getDefaultDisplay().getWidth();
layout.MainView.setVisibility(View.GONE);
layout.MainLogin.startAnimation(animationRightX1);
layout.MainRegister.startAnimation(animationRightX1);
animationRightX1.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
layout.layoutScroll.scrollTo((width*2), 0);
layout.MainView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
这里是没有动画的代码(这是你需要的):
//This code change the view so that the register form will appear. instead of changing activity
//Go to the registration form from the main view.
public void goToRegistrationPageFromMainView()
{
final int width = this.getWindowManager().getDefaultDisplay().getWidth();
layout.layoutScroll.scrollTo((width*2), 0); // its width*2 because there is the "some other view" so it need to go 2 times width to the right side...
}
所以基本上你在这里所做的是滚动具有像素宽度的窗口。
layoutscroll是图片中的粉红色。
layout 是我创建的用于存储所有布局的类...您可以根据个人喜好设置this.layoutscroll...。
- 主视图、其他视图和注册表单是扩展线性布局的自定义视图...您可以使用线性布局充气器将 XML 文件附加到每个视图...