java - 是否可以在布局中混合使用“SurfaceView”和另一个“View”?
问题描述
我想要一个LinearLayout
包含 aSurfaceView
和 aView
作为我的内容的水平Fragment
。假设它们应该覆盖整个屏幕,宽度和高度相同。
当我尝试这个时,我只得到一个SurfaceView
覆盖整个屏幕的 a,这让我想知道是否可以混合 aSurfaceView
和 another 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>
解决方案
现在找到了解决方案!
当我ImageView
使用 Android Studio 的图形编辑器在我的布局中添加一个新的时,图像源会加载该app:srcCompat
属性。如果我将其替换为android:src
,则图像大小正确并且FrameLayout
按预期显示。
推荐阅读
- discord.js - 试图只为管理员提供踢球功能
- c# - 使用反射访问远程父类中的私有字段返回 null
- mule - Mule SDK 问题 - 无法使用 @MetadataKeyId 获取元数据的密钥
- templates - 如何将所选元素转换为透明对象
- java - 无法在子包中创建类的实例
- php - 如何在 Lumen 中自定义 ValidationException 响应?
- tensorflow-federated - 为什么 tensorflow 联合的性能比单个 Keras 模型差
- javascript - 当原点实际上相同时,如何解决“帧被阻止......跨原点..”错误?
- assembly - 如何使计时器起作用?启动后 5 秒调用 int 4ah
- python - 循环numpy数组v/s映射函数?