SwipeBackDemo

The APP is provided with a sliding gesture to close the current page. The introduction of this scheme has little change to the original project, just two Java files.

Special thanks to

This project is based on LiuGuangqiang’s SwipeBack Library, thanks to the original author!

Results the preview

At the same time, you can also scan the QR code to download APK to the mobile phone for experience.





My change

  • You do not need to set a transparent theme.

    • Avoid side effects caused by this theme, such as: the Activity switch animation fails, VideoView/SurfaceView becomes transparent and cannot display content, some phones will display the desktop when sliding closed. However, the effect of sliding along with gestures is also removed. The current sliding effect is similar to the right slide closing effect of Sina Weibo or QQ. You can see the preview effect of dynamic pictures.
  • The sliding gesture does not conflict with the sliding controls in the interface.

    • The trigger of sliding is edge trigger. ACTION_DOWN, the default gesture, can trigger the action of sliding to close within 50 pixels of the edge of the screen. If the sliding distance exceeds a certain distance, the action of closing the current Activity will be executed. If ACTION_DOWN falls more than 50 pixels from the edge of the screen, the trigger action is handed to the interface View without interception.

How to use

  • Download the project to the local computer and download theSwipeBackAppCompatActivity.javaSwipeBackLayout.javaCopy the two files and some resource properties to the corresponding directory or file of your own projectBaseActivityInheritance toSwipeBackAppCompatActivity
  • If you want to animate your Activity like Demo, copy the animation file in the anim directory to your own project, and then configure the animation theme for your Activity



    Gradle Dependencies dependencies are not supported. Hahaha, because one is only a few files are directly copied, and two is that I haven't published the files uploaded to JCenter, and I don't plan to upload them.)



License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copy the code