Android 安卓另一个布局上的透明布局

Android 安卓另一个布局上的透明布局,android,layout,transparent,Android,Layout,Transparent,我正在开发视频播放器,我需要在视频视图上显示SeekBar、当前时间文本视图、视频长度文本视图。我还需要把它放到任何有透明背景的布局中。我在Stackoverflow中阅读了一些主题,但它们无助于解决我的问题。谁能帮帮我吗!非常感谢! 这是我的videoplayer的xml布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/

我正在开发视频播放器,我需要在视频视图上显示SeekBar、当前时间文本视图、视频长度文本视图。我还需要把它放到任何有透明背景的布局中。我在Stackoverflow中阅读了一些主题,但它们无助于解决我的问题。谁能帮帮我吗!非常感谢! 这是我的videoplayer的xml布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/video_main_container"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >
 <!-- This is Layout that must be in the top of my video view --->
<LinearLayout
    android:id="@+id/streams"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:background="#40ffffff"
    android:orientation="horizontal"
    android:visibility="gone" >

    <Spinner
        android:id="@+id/language_spinner"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <Spinner
        android:id="@+id/subtitle_spinner"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <ImageView
        android:id="@+id/full_screen"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_weight="1"
        android:src="@drawable/logo_fullscreen" />

</LinearLayout>
<!-- This is layout with seekbar and text views with current time, video file length -->
<!-- I need to show it on the bottom of my video view -->
<RelativeLayout
    android:id="@+id/controls"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:backgroundDimEnabled="true"
    android:background="#00ffffff"
    >

    <Button
        android:id="@+id/play_pause"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:drawable/ic_media_play"
        android:contentDescription="@null"
        android:enabled="false" />

    <Button
        android:id="@+id/scale_type"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/play_pause"
        android:background="@android:drawable/ic_menu_info_details"
        android:enabled="true" />

    <SeekBar
        android:id="@+id/seek_bar"
        android:alpha="0.5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/scale_type" />

    <TextView
        android:layout_margin="3dp"
        android:id="@+id/current_time_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/seek_bar"
        android:layout_alignLeft="@+id/seek_bar"
        android:text="" />

    <TextView
        android:layout_margin="3dp"
        android:id="@+id/video_length_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/seek_bar"
        android:layout_alignRight="@+id/seek_bar"
        android:text="" />

</RelativeLayout>
    <!-- This is my VideoView, all controls I must display over it --->
<com.ffmpeg.FFmpegSurfaceView
    android:id="@+id/video_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@+id/controls"
    android:layout_below="@+id/streams"
    android:visibility="visible" />
</RelativeLayout>

在实现所有其他功能之后,您正在实现视频视图。如果您使用的是RelativeLayout,则应首先添加视频视图,然后在其上搜索

如下所示:



在styles.xml中创建新样式。比如:

    <style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>

真的
@android:彩色/透明
@空的
真的
真的
假的
并将其用作清单中的活动主题。例如:

        <activity
        android:name="...."
        android:label="@string/app_name"
        android:theme="@style/Theme.Transparent" 
       ......

不确定这里的实际问题是什么,但是如果您希望这些控件位于FFmpegSurfaceView的顶部(按Z顺序),它们应该出现在该布局文件中的之后。

最好使用framelayout使哪个布局透明。我想使所有布局透明。我的视频视图必须是全屏的,其他控件必须在透明布局的顶部。这里是一个例子是的,我需要在我的视图顶部显示这些控件。不是的,我需要在我的视频视图顶部显示所有这些控件,就像在这张图片上看一看我写的xml。它也在做同样的事情:)用Videoview和ViewView下面的RelativeLayout中的所有其他东西替换你的自定义视频播放器。试试看。会有用的谢谢你,鲁迪!我会试着改变你写的布局。顺便问一下,我在哪里可以找到你正在使用的FFmpeg播放器?鲁迪,你是天才。代码工作得非常好!非常感谢你!!!!我使用的是FFmpegPlayer,你们可以在这个链接上找到。对不起,我忘了在我的问题中添加我需要的示例链接。这里是它的图片是我的视频视图和文本在透明是一个透明布局与搜索栏其他控件的例子。
        <activity
        android:name="...."
        android:label="@string/app_name"
        android:theme="@style/Theme.Transparent" 
       ......