我有一个绘制一个自定义视图的 HUD
I have a custom view that draws HUD:
下面是我的布局:
<?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" >
<VideoView
android:id="@+id/videoView1"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.widgets.HUD
android:id="@+id/hud"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.hud_fragment, container, false);
frameLayout = (FrameLayout) view.findViewById(R.id.frameLayout);
hudWidget = (HUD) view.findViewById(R.id.hudWidget);
videoView = (VideoView) view.findViewById(R.id.videoView1);
videoView.setVideoURI(Uri.parse("http://88.150.210.138:5001/spor"));
videoView.start();
frameLayout.removeView(hudWidget);
frameLayout.addView(hudWidget);
hudWidget.bringToFront();
return view;
}
我上播放的 RTSP 流我的 VideoView 一旦视频开始播放它看起来像:
I play an RTSP stream on my VideoView as soon as the video starts playing it looks like that:
我怎么能强迫HUD借鉴的 VideoView 热门? HUD延伸SurfaceView
How can i force the HUD to draw on top of the VideoView? HUD extends SurfaceView
我发现你的问题的答案:的 VideoView在SurfaceView的顶部的SurfaceView和VideoView都是表面的观点,并没有得到支持,因为2.0重叠这些旧版本的Android,但可用。
I found the answer for your question: VideoView on top of SurfaceView The SurfaceView and the VideoView are both surface views and it was not supported to overlap these in old versions of Android but available since 2.0.
您需要做的:
将像素格式为透明的,以便让通过接口视频大放异彩 hudWidget.getHolder()和setFormat(PixelFormat.TRANSPARENT);
hudWidget.setZOrderMediaOverlay(真);
有一个拉请求,在那里你可以尝试这些。 https://github.com/arthurbenemann/droidplanner/pull/247
There is a pull request where you can try these. https://github.com/arthurbenemann/droidplanner/pull/247
这带来了解决方案的线程:的https://groups.google.com/forum/?fromgroups#!msg/android-developers/nDNQcceRnYA/ps9wTBfXIyEJ
The thread that brought the solution: https://groups.google.com/forum/?fromgroups#!msg/android-developers/nDNQcceRnYA/ps9wTBfXIyEJ