如何显示来自android应用程序的360全景



我想从我的android应用程序中显示一个全景图,这个全景图是在线的,我有它的url,我将它加载到网络视图中,但它无法正常工作。它只是它的一部分,不会颠倒或移动。我不知道从哪里开始,你能给我指明正确的方向吗?提前感谢

经过大量研究,我发现这个库仍然很新,但肯定可以帮助您从一些方面入手。我发布它只是为了给其他搜索者节省时间!干杯全景Gl

我在Kotlin遇到过类似的情况,但我需要从URL获取图像。我用毕加索解决了这个问题。我把这个留到这里供将来参考:

    val options = VrPanoramaView.Options()
    val url = "https://urltoyourimage.com/image.jpg"
    Picasso.get().load(url)
        .into(object : Target {
            override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
                options.inputType = VrPanoramaView.Options.TYPE_MONO
                vrPanoramaView.loadImageFromBitmap(bitmap, options)
            }
            override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {
                print(e?.localizedMessage)
            }
            override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
                print(placeHolderDrawable)
            }
    })
  1. 在gradle(应用程序级别)中添加依赖项

    compile 'com.google.vr:sdk-panowidget:1.80.0'

  2. 在你的xml中添加VrPanoramaView,并在android 中通过findViewById()方法获得引用

  3. 以下是从资产加载图像的代码。

VrPanoramaView将输入作为位图,因此我们需要首先将其转换为正确的格式。这里,loadPhotoSphere起作用在onCreate() 中调用

private void loadPhotoSphere() {
  VrPanoramaView.Options options = new VrPanoramaView.Options();
  InputStream inputStream = null;
  try {
      inputStream = assetManager.open("image.jpg");
      options.inputType = VrPanoramaView.Options.TYPE_MONO;
      mVRPanoramaView.loadImageFromBitmap(BitmapFactory.decodeStream(inputStream), options);
      inputStream.close();
  } catch (Exception e) {
      e.printStackTrace();
  }
}

点击此处阅读Android版谷歌VR SDK

最新更新