[英]How to make SurfaceView transparent and behind the ViewHierarchy
最近,我用SurfaceView创建了一个复杂的View,我觉得很复杂。我发现SurfaceView的背景是黑色的,并通过使用SurfaceView.setZOrderOnTop()将其背景更改为透明。但是还有一个问题是Surfaceview不是观念层次的背后。 我的目的是让surfaceview变得透明并且在viewhierarchy后面,有什么解决方案吗? 对不起我的英语不好!
像这样的一些 xml 布局代码
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SurfaceViewActivity">
<com.example.testproject.customview.AnimationView
android:id="@+id/animationview"
android:layout_width="400dp"
android:layout_height="400dp"
android:layout_gravity="center"
android:background="@android:color/transparent"
/>
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:background="@null"
android:layout_gravity="center"
android:visibility="visible"
android:src="@drawable/ic_launcher_foreground"
/>
</FrameLayout>
'AnimationView' 是 SurfaceView 的扩展
我认为我的开始方向是错误的,因为 android.view.View hardwareAccelerator 默认是打开的,并且我将我的代码从 SurfaceView 移动到 android.view.View 以测试性能我发现性能足够了,并且在结论。我没有找到解决这个问题的方法,而是换了一个方法来解决这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.