【问题标题】:android: video as background viewandroid:视频作为背景视图
【发布时间】:2011-08-16 06:58:14
【问题描述】:

我想在视图的背景中播放视频。在视图中我想要一些其他视图,如按钮和文本视图,可以这样做吗? 我尝试使用以下代码

RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <VideoView 
        android:scrollbars="none"
        android:clickable="false"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"      
        android:fitsSystemWindows="true"
        android:id="@+id/VideoView">
        </VideoView>
<TextView 
    android:text="hi123"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>

</RelativeLayout>

请建议我如何才能做到这一点。

谢谢。

【问题讨论】:

  • 如果您已经完成了您的代码,请更新它。我也需要做这个任务,但我很长一段时间都做不到。如果您不是我的,请在此处更新您的方式/代码。谢谢

标签: android-video-player


【解决方案1】:

不确定是否可以将 videoView 放在后台。 更好的选择是使用具有透明背景的框架布局,并将其他视图放在其顶部。

【讨论】:

  • 感谢帮助,它正在工作,但我已将相对布局放在框架布局内,然后相对布局属性无法像下面/上面那样工作,有什么办法吗?
  • Framelayout 与 relativelayout 合并时不能成为问题。我用过它,它对我来说很好用。也许您可以再次检查 xml 文件中的属性来确定问题。
【解决方案2】:

Shafi 是对的,我只是发布了我所做的代码,

 <merge xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<VideoView  
        android:scrollbars="none"
        android:clickable="false"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"      
        android:fitsSystemWindows="true"
        android:id="@+id/videoView"

         />.....

我希望这段代码可以帮助一些人。 谢谢

【讨论】:

  • Sameer,您的视频播放器的 Java 代码是什么样的?你能分享一下吗?我收到一条弹出消息,提示“无法播放视频”。然后我得到一个黑屏。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-26
  • 2013-04-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多