我在缩略图webview和全屏webview中加载相同的MJPG流,这样当你点击缩略图时,它会快速显示全屏。现在,我为缩略图加载一次,然后当用户单击缩略图时,它会再次加载它以获得全屏视图。问题是这需要几秒钟而且是不可接受的。
所以问题是如何在两个网页浏览之间共享相同的加载数据,以便全屏webview几乎立即加载?
以下是我现在用于制作全屏缩略图的代码:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Threading.Tasks;
using Android.Webkit;
namespace TestApp
{
[Activity(Label = "TestApp", MainLauncher = true, Theme = "@style/Theme.DesignDemo")]
public class MainActivity : AppCompatActivity
{
WebView webView, webViewFull;
// Just sample images.....these will be video streams later
String URL1 = "http://8-themes.com/wp-content/uploads/2015/12/a1fc35e49c1d62c0210462d6ae613b0d-320x240.jpg";
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
webView = FindViewById<WebView>(Resource.Id.webView1);
webView.Settings.LoadWithOverviewMode = true;
webView.Settings.UseWideViewPort = true;
webView.LoadUrl(URL1);
webViewFull = FindViewById<WebView>(Resource.Id.webViewFull);
webViewFull.Settings.LoadWithOverviewMode = true;
webViewFull.Settings.UseWideViewPort = true;
webView.Touch += (sender, e) =>
{
if (e.Event.Action == MotionEventActions.Up)
{
webViewFull.Visibility = ViewStates.Visible;
cameraSettingsButton.Visibility = ViewStates.Visible;
webViewFull.LoadUrl(URL1);
webView.RequestLayout();
}
};
}
}
}
布局文件:
<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<GridLayout
android:id="@+id/camera_layout"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginTop="30dp"
android:rowCount="10"
android:columnCount="5"
android:visibility="visible"
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_y="400dp">
<android.webkit.WebView
android:id="@+id/webView1"
android:layout_row="0"
android:layout_column="0"
android:layout_marginLeft="35dp"
android:layout_width="300dp"
android:layout_height="240dp" />
</GridLayout>
<android.webkit.WebView
android:id="@+id/webViewFull"
android:layout_x="0dp"
android:layout_y="0dp"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="match_parent" />
</AbsoluteLayout>
我只是在学习Xamarin,所以任何想法都会受到高度赞赏!