Android realizes the effect similar to IOS right sliding return (cause analysis and solution)

Using the class library swipebacklayout

https://github.com/Issacw0ng/SwipeBackLayout

Problems:

1. When the main activity returns, the screen is black or you only see the desktop background without seeing the previous activity interface

reason:

When using sliding return, you need to declare Android: windowsistranslucent = true in the content topic of the activity, and this property is to set whether the activity is a transparent topic. When the main activity adopts a transparent topic, because it is the first in the app activity stack, you will see the desktop or black screen when sliding return

solve:

The main activity does not need to turn on the sliding return function (it is not required by itself). It is only used for the activities that need sliding return. You can define the following themes and set themes for different activities as needed:

2. Another problem occurs in the life cycle of activity switching:

When the user opens a new activity or switches to the desktop, the callback is as follows: onpause - > onstop

There is a special case here. If the new activity adopts a transparent theme, the current activity will not call back onstop

Sometimes it is necessary to do some processing in onstop. If a transparent theme is used, it will not be called. An alternative is to execute it in onpause. Of course, it should be noted that neither onstop nor onpause can perform too time-consuming operations, otherwise it will affect the start of a new activity

The above is what Xiaobian introduced to you. Android realizes the effect similar to IOS right sliding return (cause analysis and solutions). I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>