我正在尝试展示一个SurfaceView
内部Activity
主题,该主题可以扩展Theme.Dialog
(您可以认为我正在尝试在Dialog
类中展示它),但我遇到了一些布局故障。
我无法拍照,因为截图时故障消失了:/但无论如何你看到的是“洞”SurfaceView
从其原始位置移动并产生了一些奇怪的叠加效果......
问题似乎与标志有关windowIsFloating
,如果我将其设置为 false 故障就会消失......
关于继续使用windowIsFloating
标志的可能解决方法的任何想法?
重现问题的简单布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<FrameLayout android:id="@+id/container"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerInParent="true"
android:padding="30dp"
android:background="#ff0">
<SurfaceView android:id="@+id/surface"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
并像这样修改您的活动主题以重现该问题:
<style name="MyTheme" parent="@android:style/Theme">
<item name="android:windowIsFloating">true</item>
</style>