用SwipeBackLayout让activity具有滑动返回的效果
生活随笔
收集整理的這篇文章主要介紹了
用SwipeBackLayout让activity具有滑动返回的效果
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
項目地址:
https://github.com/ikew0ng/SwipeBackLayout
一、讓需要滑動的Activity基礎自定義的style
這里就是為了解決滑動黑屏的問題
<resources><!--Base application theme, dependent on API level. This theme is replacedby AppBaseTheme from res/values-vXX/styles.xml on newer devices.--><style name="AppBaseTheme" parent="Theme.AppCompat.Light"><!--Theme customizations available in newer API levels can go inres/values-vXX/styles.xml, while customizations related tobackward-compatibility can go here.--></style><!-- Application theme. --><style name="AppTheme" parent="AppBaseTheme"><!-- All customizations that are NOT specific to a particular API-level can go here. --></style><style name="KaleTheme" parent="AppBaseTheme"><!-- 解決activity切換時的黑屏問題 --><item name="android:windowIsTranslucent">true</item> </style> </resources>我是直接用Application使用了這個樣式,僅僅為了演示。
<applicationandroid:allowBackup="true"android:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/KaleTheme" >
二、 用Activity繼承一個類
如果你是要兼容Actionbar那么就繼承SwipeBackActionbarActivity,這個類是我自己改的,原來的lib中沒有。如果不用兼容,那么直接用SwipeBackActivity即可。
三、在方法中找到SwipeBackLayout,并設置滑動的區域和方向
這個就是簡單的設置,我直接貼代碼了。
總結
以上是生活随笔為你收集整理的用SwipeBackLayout让activity具有滑动返回的效果的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OkHttp使用介绍 和 使用进阶
- 下一篇: Android 手势解锁 Gesture