代码之家  ›  专栏  ›  技术社区  ›  roxy

ImageView是否在VideoView上可见?

  •  -1
  • roxy  · 技术社区  · 7 年前

    我希望能够在imageview中设置可见图像( 在视频视图中播放视频时占据半个屏幕)。有可能吗?

    2 回复  |  直到 7 年前
        1
  •  0
  •   Sachin Varma    7 年前

    创建这样的xml,

    为视图添加相等的权重,并使其高度为0dp,这将需要相等的高度。

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >
    
      <ImageView
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:background="#ccc"
          />
      <VideoView
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          />
    </LinearLayout>
    

    它会帮助你的。

        2
  •  0
  •   roxy    7 年前

    谢谢你,我正在尝试这样的相对布局,但当我更改图像可见性时,视频覆盖了图像。。。我想要的是相反的,视频上的图像。

    <RelativeLayout 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"
        tools:context=".PatternSelection" >
        <ImageView
            android:id="@+id/settse"
            android:layout_width="480dp"
            android:layout_height="270dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:visibility="invisible"
            app:srcCompat="@drawable/sett" />
    
        <VideoView
            android:id="@+id/videoView"
    
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true" />
    
    </RelativeLayout>