是否可以在布局中混合使用“SurfaceView”和另一个“View”?
Is it possible to mix a `SurfaceView` and another `View`s in a layout?
我想要一个包含 SurfaceView
和 View
的水平 LinearLayout
作为我的 Fragment
的内容。假设它们应该覆盖整个屏幕,宽度和高度大小相同。
当我尝试这个时,我只得到一个覆盖整个屏幕的 SurfaceView
,这让我想知道是否可以混合一个 SurfaceView
和另一个 View
。
有谁知道这是否可能,如果可能,应该怎么做?
我的布局文件:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<SurfaceView
android:id="@+id/SurfaceView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"></SurfaceView>
<FrameLayout
android:id="@+id/AV"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:visibility="visible">
<ImageView
android:id="@+id/FAV"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/fond_vertical" />
<ImageView
android:id="@+id/CV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/curseur" />
</FrameLayout>
</LinearLayout>
现已找到解决方案!
当我使用 Android Studio 的图形编辑器在布局中添加新的 ImageView
时,图像源加载了 app:srcCompat
属性。如果我用 android:src
替换它,图像大小正确并且 FrameLayout
按预期显示。
我想要一个包含 SurfaceView
和 View
的水平 LinearLayout
作为我的 Fragment
的内容。假设它们应该覆盖整个屏幕,宽度和高度大小相同。
当我尝试这个时,我只得到一个覆盖整个屏幕的 SurfaceView
,这让我想知道是否可以混合一个 SurfaceView
和另一个 View
。
有谁知道这是否可能,如果可能,应该怎么做?
我的布局文件:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<SurfaceView
android:id="@+id/SurfaceView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"></SurfaceView>
<FrameLayout
android:id="@+id/AV"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:visibility="visible">
<ImageView
android:id="@+id/FAV"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/fond_vertical" />
<ImageView
android:id="@+id/CV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/curseur" />
</FrameLayout>
</LinearLayout>
现已找到解决方案!
当我使用 Android Studio 的图形编辑器在布局中添加新的 ImageView
时,图像源加载了 app:srcCompat
属性。如果我用 android:src
替换它,图像大小正确并且 FrameLayout
按预期显示。