[英]Android - Layout SurfaceView and Image View
嘗試將圖像視圖放在表面視圖之上時出現錯誤。
這是我的XML代碼,請在這方面幫助我
<?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="wrap_content"
android:background="@android:color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EFE3AF"
android:orientation="vertical" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="500dp"
android:layout_weight="1"
>
<SurfaceView
android:id="@+id/surfaceview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null"
android:scaleType="fitXY"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:gravity="right"
android:orientation="vertical"
android:paddingRight="@dimen/right01"
android:paddingTop="@dimen/top02" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/village" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</RelativeLayout>
如果我要增加表面視圖和減少圖像,以上代碼可以正常工作,但是我想采用其他方法。
像這樣嗎
<?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="wrap_content"
android:background="@android:color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EFE3AF"
android:orientation="vertical">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="500dp"
android:layout_weight="1">
<SurfaceView
android:id="@+id/surfaceview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null"
/>
<ImageView
android:layout_gravity="top|right"
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000" />
</FrameLayout>
</LinearLayout>
</RelativeLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.