[英]Android: SurfaceView
我有帶有setZOrderOnTop(true)
的SurfaceView。在繪制過程中,透明SurfaceView的背景需要此標志。
如何在其前面顯示任何視圖?
以我的經驗,這仍然有效。 但是,如果您使用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的頂部...(我想是嗎?)
SurfaceView並非旨在與其他視圖合成。 如setZOrderOnTop的文檔中所述 ,一旦設置了此模式,其他任何窗口內容都不會在SurfaceView頂部可見。
如果要進行合成,則必須自己在屏幕外進行,然后將結果繪制到SurfaceView中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.