Android透明活动背景重复问题
我已经使用样式进行了透明活动:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_gravity="bottom"
android:layout_margin="8dp"
android:background="@drawable/notification_layout_rect"
android:id="@+id/clWin"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="250dp">
</LinearLayout>
和代码:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
makeStatusBarTransparent()
}
private fun makeStatusBarTransparent() {
if (Build.VERSION.SDK_INT >= 21) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.statusBarColor = resources.getColor(android.R.color.transparent)
}
}
}
问题:但是,当我多次单击“概述”导航按钮时,我得到了背景复制效果。有解决此问题的方法吗?
问题至少可以在android 5.1.1和7.0上再现
源代码:https://www.dropbox.com/s/6xghi6a3wten42a/TransparentActivity.zip?dl=0