我有一个带有setZOrderOnTop(true)的SurfaceView,在绘制过程中透明的SurfaceView的背景需要.This标志。
如何在其前面显示任何视图?
发布于 2012-02-07 20:02:41
SurfaceViews不是为与其他视图组合而设计的。正如setZOrderOnTop文档中所述,一旦设置了此模式,SurfaceView上的任何其他窗口内容都将不可见。
如果你想做合成,你必须自己做,在屏幕外,然后将结果绘制到SurfaceView中。
发布于 2016-01-21 01:52:49
根据我的经验,这仍然有效。但是如果你使用RelativeLayout,它会很难看。
<FrameLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.applicationtest.MainActivity" >
<SurfaceView
android:id="@+id/surfaceView1"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
<LinearLayout
android:layout_marginTop="50sp"
android:orientation="vertical"
android:background="#44444444"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:text="ttttttttttttttttttttt"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="ttttttttttttttttttttt"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="ttttttttttttttttttttt"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</FrameLayout>WallPaperService使用SurfaceView。因此,没有理由没有视图不能位于SurfaceView的顶部...(我猜??)
https://stackoverflow.com/questions/9174712
复制相似问题