Recently,I use SurfaceView to create a complex View which I think it is complex.I found that SurfaceView's background is black,and change its background to transparent by using SurfaceView.setZOrderOnTop().But there is another problem is that the Surfaceview is not behind the viewhierarchy. My purpose is surfaceview become transparent and behind the viewhierarchy,is there any solutions for this? Sorry for my poor English!
Some xml layout code like this
<?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' is extends SurfaceView