SwipeBackLayout是一個很好的類庫,它可以讓Android實現類似iOS系統的右滑返回效果,但是很多用戶在使用官方提供的Demo會發現,可能出現黑屏或者返回只是看到桌面背景而沒有看到上一個Activity的UI。
https://github.com/Issacw0ng/SwipeBackLayout
解決方法如下:
不要在首頁打開滑動返回功能,而且在首頁使用AppBaseThemeMain所示的主題,在需要滑動返回的Activity使用AppBaseTheme主題,這兩個主題所設置的屬性是指是否把window變成透明的,在首頁的Activity就不能讓window變得透明,需要滑動返回的Activity就需要設置該屬性。
<style name="AppBaseTheme" parent="@android:style/Theme.Holo.Light"> <item name="android:windowIsTranslucent">true</item> </style>
<style name="AppBaseThemeMain" parent="@android:style/Theme.Holo.Light"> <item name="android:windowIsTranslucent">false</item> </style>