Two levels of activities on Android. Seamless transition

匆匆过客 提交于 2019-12-11 09:17:31

问题


The app has 3 activities: A, B and C.
"B" has style=Theme.Dialog, so it can be displayed in a fraction of the screen on top of "A" and "C".
The idea is to show "B" on top while "A" is getting replaced with "C", so the transition between "A" and "C" will appear seamless for user.

Questions:

  1. is this the right approach (or I should use PopupWindow, etc. instead of activity "B")?
  2. when activity "C" is launched, "B" is hidden and shown again (onPause/onResume called again) which is looking like "B" is blinking. Is there any way to fix this?

Illustration:

  1. initial state. "A" launched, "B" is launched on top of "A"
  2. "A" finished, "B" is still on top
  3. "C" launched, "B" blinked and brought to front (because of launchMode="singleInstance")


回答1:


I don't think you could avoid "blink" effect on B when A and B are 2 activities.

Perhaps a solution to that would be to merge A and C in same activity. Manage a state to know if new activity in in state A or C.

For instance:

boolean stateA = ...;
if(stateA){
 setContentView(R.layout.a);
 //use code of A
 [...]
}else{
 setContentView(R.layout.b);
 //use code of B
 [...]
}

It seems for me, the easier solution.



来源:https://stackoverflow.com/questions/29130417/two-levels-of-activities-on-android-seamless-transition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!