在 Android 中将任何 View 置于 VideoView 之上

发布于 2024-08-19 08:36:43 字数 118 浏览 3 评论 0原文

可以将任何视图放在 VideoView 上吗? (即将控制按钮放在视频上,就像在 vimeo 中一样)。我正在尝试使用 FrameLayout 来做到这一点,但我还没有找到方法,而且我仍然不确定我想做的事情是否根本不可能。

It is possible to put any view over a VideoView? (I.e. put the control buttons over the video, like in vimeo). I'm trying to do it using FrameLayout, but I have not found the way, and I'm still not sure if what I'm trying to do something that's is simply not possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林散布 2024-08-26 08:36:43

我用 FrameLayout 做这种事情。您需要做的是确保控件位于布局编辑器中的 VideoView 下方。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@color/MenuTextNormal">

    <VideoView
        android:id="@+id/VideoView"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/ControlLayout"
        android:layout_gravity="bottom|center_horizontal">

        <Button
            android:text="@+id/Button01"
            android:id="@+id/Button01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:text="@+id/Button02"
            android:id="@+id/Button02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:text="@+id/Button03"
            android:id="@+id/Button03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:text="@+id/Button04"
            android:id="@+id/Button04"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</FrameLayout>

I do this sort of thing with FrameLayout. What you need to do is make sure that the controls are below the VideoView in the Layout Editor.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@color/MenuTextNormal">

    <VideoView
        android:id="@+id/VideoView"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/ControlLayout"
        android:layout_gravity="bottom|center_horizontal">

        <Button
            android:text="@+id/Button01"
            android:id="@+id/Button01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:text="@+id/Button02"
            android:id="@+id/Button02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:text="@+id/Button03"
            android:id="@+id/Button03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:text="@+id/Button04"
            android:id="@+id/Button04"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</FrameLayout>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文