android-studio - 在视频 View 中显示按钮

标签 android-studio android-xml android-button android-videoview

如何使用 android studio 在视频 View 中显示按钮?该按钮似乎在那里但不可见。

<RelativeLayout>

    <VideoView 
        android:id="@+id/vV"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"/>

    <Button
        android:id="@+id/btn"
        android:text="btn"/>

</RelativeLayout>

我希望该按钮在视频 View 中可见。该按钮可点击但不可见

最佳答案

通过添加使用约束布局

implementation 'com.android.support.constraint:constraint-layout:1.0.2'

到你的毕业典礼
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
    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:background="@color/colorbackground">

    <VideoView
        android:id="@+id/videoView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.8" />
</android.support.constraint.ConstraintLayout>

关于android-studio - 在视频 View 中显示按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47171004/

相关文章:

android - 如何在 Android Studio 中为演示和完整 flavor 代码创建适当的目录?

java - 应用程序关闭时 Android Studio 音频停止播放

Android Studio 不会导入 SVG Vector 的所有部分

java - 在 Java 文件而不是 xml 中定义颜色常量

java - 为什么DDMS不再开放?

Android - 如何使 TextInputEditText 的高度恰好为 2 行?

android - 如何使用 ConstraintLayout Flow 对齐元素

java - 如何缩小按钮的点击区域?

android - 按钮超出布局时会被挤压

android - 在同一水平线上点亮两个按钮