android - 更改 Activity 时如何更改默认动画?

标签 android animation button android-activity homescreen

您好,我有一个应用程序,我可以触摸它来滚动多个屏幕,例如 Android Homescreen应用程序。

我现在已经设法在每个页面上添加一个按钮,从这个按钮变成一个新的 Activity ,但是滚动是从左到右的,我希望它在单击按钮时向下滚动,但我不知道如何去做。

(这可能是一个非常菜鸟的问题 - 对此感到抱歉。)

这是我的 main.java 文件

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);

        Button onebutton = (Button)findViewById(R.id.soundsone);
        onebutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series1button.class);
        startActivity(i);

    }
});


        Button twobutton = (Button)findViewById(R.id.soundstwo);
        twobutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series2button.class);
        startActivity(i);

    }
});  
        Button threebutton = (Button)findViewById(R.id.soundsthree);
        threebutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series3button.class);
        startActivity(i);

    }
});        Button fourbutton = (Button)findViewById(R.id.soundsfour);
        fourbutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series4button.class);
        startActivity(i);

    }
});        Button fivebutton = (Button)findViewById(R.id.soundsfive);
        fivebutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series5button.class);
        startActivity(i);

    }
});        Button sixbutton = (Button)findViewById(R.id.soundssix);
        sixbutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series6button.class);
        startActivity(i);

    }
});        Button sevenbutton = (Button)findViewById(R.id.soundsseven);
        sevenbutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series7button.class);
        startActivity(i);

    }
});        Button eightbutton = (Button)findViewById(R.id.soundseight);
        eightbutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series8button.class);
        startActivity(i);

    }
});
    }
}

最佳答案

您可以引用example在 apidemos 的目录中,它使用 overridePendingTransition 来显示自定义动画。还有与此主题相关的另一篇文章:Can I change the Android startActivity() transition animation?

关于android - 更改 Activity 时如何更改默认动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5026935/

相关文章:

android - 如何单击 fragment 中的按钮以切换到 Kotlin 中的其他选项卡?

java - Oracle JRE 和 Dalvik JVM 上的不同结果

java - Google Play 游戏服务中基于套接字与不可靠的消息传递

animation - 第二次点击时 SVG 动画反转

iphone - 用于推送 UIViewController 的自定义动画

javascript - Watir 和 Javascript 按钮

android - 我们如何在滚动 recyclerview android 的同时滚动父布局

ios - UIView animateWithDuration 如何通过触摸事件取消(不与 MapView 交互)

java - 使用 Android 在单击按钮时播放声音

delphi - 如何在Delphi FireMonkey中调整按钮大小以适合文本?