I use a XWalkView https://crosswalk-project.org/加载网页和视频查看器 https://github.com/Bilibili/ijkplayer在我的应用程序中播放实时视频。我希望 IjkVideoView 在 XwalkView 前面播放视频,因此我将这两个视图放在相对布局中,并将 IijVideoView 放在 XWalkView 后面。
在 android studio 的“设计组件树”窗口中,布局看起来不错,如下图所示,
当我在设备中运行该应用程序时,布局很混乱,如下图所示。可以看到IjkVieoView的背景在XWalkView的前面,但是IjkVideoView中播放的视频在XWalkView的后面,因为视频的上半部分已经被XWalkView覆盖了。
布局 XML,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
<!-- This could be your fragment container, or something -->
<org.xwalk.core.XWalkView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/xWalkView"
android:layout_width="fill_parent"
android:layout_height="160dp"
android:background="@color/blue"
android:isScrollContainer="true">
</org.xwalk.core.XWalkView>
<com.xxxxxx.app.widget.media.IjkVideoView
android:id="@+id/video_view"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="72dp"
android:background="@color/colorAccent" />
<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="@xml/web_tabs" />
</RelativeLayout>
</LinearLayout>
活动java代码,
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("INFO", "entered");
setContentView(R.layout.activity_web);
mXWalkView = (XWalkView) findViewById(R.id.xWalkView);
XWalkSettings webSettings = mXWalkView.getSettings();
webSettings.setJavaScriptEnabled(true);
mXWalkView.addJavascriptInterface(new JsInterface(), "NativeInterface");
videoView = (IjkVideoView) findViewById(R.id.video_view);
videoView.setAspectRatio(IRenderView.AR_ASPECT_FILL_PARENT);
videoView.setVideoURI(Uri.parse("http://live.xxxxxx.com/live/40xx27.flv"));
videoView.start();
final Bundle extras = getIntent().getExtras();
mXWalkView.load("http://xxxxxxxxxxxxxx", null);
}
您的布局似乎是正确的。它可能从库中被破坏。它已经有超过 1000 个问题。
也许您可以使用其中包含视频的自定义对话框并显示该对话框。这样视频就会位于图像前面。然后你可以尝试去除阴影或bgColor = transparent
,这样用户可能不会意识到这是一个对话框。这个黑客可能会起作用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)