我试着解决这个问题有一段时间了,但我不知道出了什么问题。
我有一个“网络视图”如下
webView = FindViewById<WebView>(Resource.Id.thebrowserWebViewRss);
LinearLayout MainView = FindViewById<LinearLayout>(Resource.Id.rootviewRFeedbrwoser);
NestedScrollView ContentLayout = FindViewById<NestedScrollView>(Resource.Id.thebrowserScrollerViewRss);
FullScreenClient fullScreenClient = new FullScreenClient(MainView, ContentLayout)
{
ParentActivity = this
};
webView.SetWebChromeClient(fullScreenClient);
webView.Settings.JavaScriptEnabled = true;
webView.Settings.LoadWithOverviewMode = true;
我的FullScreenClient如下
public class FullScreenClient : WebChromeClient
{
readonly FrameLayout.LayoutParams matchParentLayout = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent,
ViewGroup.LayoutParams.MatchParent);
readonly ViewGroup content;
readonly ViewGroup parent;
View customView;
int counter = 0;
public WebBroswerRSS ParentActivity;
public FullScreenClient(ViewGroup parentview, ViewGroup contentview)
{
this.parent = parentview;
this.content = contentview;
}
public override void OnShowCustomView(View view, ICustomViewCallback callback)
{
customView = view;
view.LayoutParameters = matchParentLayout;
parent.AddView(view);
}
public override void OnHideCustomView()
{
content.Visibility = ViewStates.Visible;
parent.RemoveView(customView);
customView = null;
}
}
它的工作很好,虽然当我点击任何视频全屏,它会全屏,但它的所有黑色。我能听到背景中的视频声音,但看不到视频。
知道我做错了什么吗?
这是我的web浏览器的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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:id="@+id/rootviewRFeedbrwoser"
android:background="#ffffff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<ImageView
android:id="@+id/closer"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:padding="5dp"
android:src="@drawable/ic_left_arrow_black" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<ImageView
android:id="@+id/sharingIt"
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@drawable/ic_share"
android:layout_gravity="right"
android:tint="#6E6E6E"
android:layout_marginRight="10dp"
android:padding="8dp"
/>
</LinearLayout>
</RelativeLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/thebrowserScrollerViewRss"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView
android:id="@+id/thebrowserWebViewRss"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp" />
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>