安卓:就像切换桌面主页的应用程序活动之间如何切换?就像、应用程序、桌面、主页

2023-09-12 04:59:44 作者:零度饮过冰

我开发一个Android应用程序,有三个非常类似的活动。我希望用户能够刷卡左,右屏幕上它们之间进行切换。 这是我如何管理,截至目前:

I'm developing an Android Application that has three very similar Activities. I would like the user to be able to switch between them by swiping left and right on the screen. This is how I managed that up to now:

我跟着这个帖子

然后,我用这种方法改变了方法onSwipe():

Then I changed the method onSwipe() in this way:

@Override
 public void onSwipe(int direction) {
  Intent intent = new Intent();

  switch (direction) {

  case SimpleGestureFilter.SWIPE_RIGHT:
   intent.setClass(this, TodoTodaySheet.class);
   break;
  case SimpleGestureFilter.SWIPE_LEFT:
   intent.setClass(this, TrashSheet.class);
   break;

  }
  startActivity(intent);
 }

它的工作原理,但我并不完全满意。此外,我不知道这是正确的做法。

It works but I'm not completely satisfied with this. Moreover, I don't know if this is the correct approach.

我想有像切换桌面时,一个在家庭的应用程序,一个行为。因此,我想一个平滑的动画和被叫活动的正确方向的外观,例如。从屏幕的左侧,右侧刷卡时

I would like to have a behavior like the one on Home apps, when switching desktop. Therefore I would like a smoother animation and the appearance of the called activity from the right direction, eg. from the left side of the screen when swiping on the right.

任何提示?非常感谢你。

Any hints? Thank you very much.

推荐答案

在主屏幕不活动,它只是春联之间的不同意见之间滚动,你可以在其源$ C ​​$ C (线298就是屏幕的变化)。

The home screen doesn't scroll between activities it only scrolls between differing views as you can see in its' source code (line 298 is where the screens are changed).

如果你正在你的用户的配置和放大器的怜悯活动之间的切换;这些设备的能力,以恰好显示在转换过程中有什么,所以没有很多可以做。

If you're switching between activities you're at the mercy of the users configuration & the devices abilities as to what happens to the display during the transition, so there isn't a lot you can do.