【问题标题】:Is it possible to mix a `SurfaceView` and another `View`s in a layout?是否可以在布局中混合使用“SurfaceView”和另一个“View”?
【发布时间】:2020-04-12 15:59:59
【问题描述】:

我想要一个水平的LinearLayout,其中包含一个SurfaceView 和一个View 作为我的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>

【问题讨论】:

  • 在此处显示您的布局文件!
  • 布局已添加到问题中!

标签: java android surfaceview


【解决方案1】:

现在找到了解决方案!

当我使用 Android Studio 的图形编辑器在我的布局中添加新的 ImageView 时,图像源会加载 app:srcCompat 属性。如果我将其替换为android:src,则图像大小正确,FrameLayout 会按预期显示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-15
    • 2013-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多