如何在 Android 中水平/垂直滚动全景图像?

     2023-02-26     117

关键词:

【中文标题】如何在 Android 中水平/垂直滚动全景图像?【英文标题】:How to horizontal/Vertical scroll a panoramic image in Android? 【发布时间】:2016-03-15 09:37:37 【问题描述】:

我正在寻找一种在 Android 中进行滚动或扫描全景图像的方法。有了这个,我的意思是显示我的图像的一部分,调整图像的高度(或垂直宽度)并自动缓慢移动滚动所有图像的视图。例如:

这张图片太大了,无法在 16:9 的设备上看到它(我的意思是有点细节),所以我想做类似的事情:

只需在屏幕上显示该部分,然后将其缓慢向右移动直到图像末尾。在图像上实现“滚动”效果。

我最近几天一直在浏览网站和互联网,我刚刚找到了 PanoramicGL 库或一些观看 360º 图像的方法。

【问题讨论】:

您尝试过将HorizontalScrollView 嵌套在ScrollView 中吗? 【参考方案1】:

这是 Scroll Click Here

您必须使用 PanoramaClient(它是 Google Play Services 的一部分)才能打开 PhotoSphere 照片。

可以在此 Android 开发人员博客文章中找到如何执行此操作的示例:

// This listener will be called with information about the given panorama.
OnPanoramaInfoLoadedListener infoLoadedListener =
new OnPanoramaInfoLoadedListener() 
@Override
public void onPanoramaInfoLoaded(ConnectionResult result,
                                 Intent viewerIntent) 
    if (result.isSuccess()) 
        // If the intent is not null, the image can be shown as a
        // panorama.
        if (viewerIntent != null) 
            // Use the given intent to start the panorama viewer.
            startActivity(viewerIntent);
        
    

    // If viewerIntent is null, the image is not a viewable panorama.
 
 ;
 // Create client instance and connect to it.
 PanoramaClient client = ...
 ...
 // Once connected to the client, initiate the asynchronous check on whether
 //the image is a viewable panorama.
 client.loadPanoramaInfo(infoLoadedListener, panoramaUri);

【讨论】:

如果您认为我的答案有用,请将其投票为最喜欢的答案,以便其他人可以使用它.. 完成了,也投票给我的解决方案。我做的最后一个方法可以帮助太多的用户【参考方案2】:

感谢 kishu,我制作了自己的方法来动态地为全景图像设置动画,具体取决于它是横向还是纵向模式。

你可以忽略该方法的方向值,我只是用它来将视频的动画从 X 更改为 Y,如果我想横向查看图像。

 public void animatePanorama(int orientation) 

    int duration;
    // The milisecons that we will use dinamically for the animation, been this is 1,31milisecons for pixel
    float miliseconsPixel = 1.31f;
    float imageWidth;

    //Delta X and Y values for the animation
    float deltaX = 0f;
    float deltaY = 0f;
    float aspectRatio;
    //We get the drawable from the container to calcule his real Width and Height
    final Drawable d = mImageContainer.getDrawable();
    final int origWidth = d.getIntrinsicWidth();
    final int origHeight = d.getIntrinsicHeight();
    //With that we get the real aspect ratio and a duration

    if (origWidth > origHeight) 
        aspectRatio = (float) origWidth / (float) origHeight;
        duration = (int) (miliseconsPixel * origWidth);
        imageWidth = mImageContainer.getMeasuredHeight() * aspectRatio;
     else 
        aspectRatio = (float) origHeight / (float) origWidth;
        duration = (int) (miliseconsPixel * origHeight);
        imageWidth = mImageContainer.getMeasuredWidth() * aspectRatio;
    

    //Set if the animation will be horizontal(Portrait) or Vertical(landscape)
    if (orientation == 0 || orientation == 180)
        deltaX = imageWidth / 2f - mImageContainer.getMeasuredWidth() / 2;
    else
        deltaY = imageWidth / 2f - mImageContainer.getMeasuredHeight() / 2;

    //New Animation
    Animation animation = new TranslateAnimation(deltaX, -deltaX, deltaY, -deltaY);
    //Add Duration
    animation.setDuration(duration);
    animation.setFillAfter(true);
    //Add cycle for repeating mode
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.REVERSE);
    mImageContainer.startAnimation(animation);

【讨论】:

在 SwiftUi 中水平组合和打破垂直滚动视图?

...Ui?【发布时间】:2020-10-3010:50:21【问题描述】:有谁知道如何使用SwiftUi将VerticalScrollView分解为小的水平ScrollView:我有下面的代码,它垂直显示youtubeResults,因为ForEach的每个项目都较 查看详情

在 tableview 中水平滚动以及正常的垂直滚动

】在tableview中水平滚动以及正常的垂直滚动【英文标题】:Scrollinghorizontallyinthetableviewalongwithnormalverticalscroll【发布时间】:2011-09-1320:20:29【问题描述】:我的要求是在表格视图中列出板球运动员的姓名及其统计数据,如下所示... 查看详情

如何在 UINavigationBar 中水平定位 backIndicatorImage

】如何在UINavigationBar中水平定位backIndicatorImage【英文标题】:HowtohorizontallypositionthebackIndicatorImageinUINavigationBar【发布时间】:2016-01-0416:26:44【问题描述】:我使用此代码将插图添加到导航栏的backIndicator图像。但是,这仅适用于... 查看详情

iPhone UIImageView 在 UIScrollView 中水平滚动 - 中心图像?

】iPhoneUIImageView在UIScrollView中水平滚动-中心图像?【英文标题】:iPhoneUIImageViewhorizontallscrollinginUIScrollView-Centerimage?【发布时间】:2012-01-2514:37:26【问题描述】:我有根据屏幕大小下载和调整图像大小以适应图像全屏的方法。最... 查看详情

css在一个div中水平+垂直对齐3个元素

】css在一个div中水平+垂直对齐3个元素【英文标题】:cssalignhorizontally+vertically3elementswihinadiv【发布时间】:2012-04-0305:42:38【问题描述】:我正在尝试在div中为一系列3个元素设置我自己的距离:1)一个复选框2)一张图片3)一段文字... 查看详情

如何在jquery中水平滚动textarea?

】如何在jquery中水平滚动textarea?【英文标题】:howtoscrolltextareahorizontallyinjquery?【发布时间】:2013-10-2122:00:50【问题描述】:我想滚动输入字段。所以我用谷歌搜索我发现我们不能滚动输入字段,但是我们可以水平滚动文本区域... 查看详情

如何在 JavaScript 中水平翻转图像

】如何在JavaScript中水平翻转图像【英文标题】:HowtohorizontiallyflipaimageinJavaScript【发布时间】:2022-01-2211:30:48【问题描述】:我正在尝试翻转从网络摄像头流中捕获的图像。CSS中的网络摄像头view被翻转,但是当我拍摄快照时,它... 查看详情

如何在 PyQt5 中水平对齐中心图像?

】如何在PyQt5中水平对齐中心图像?【英文标题】:HowdoIaligncentreimagehorizontallyinPyQt5?【发布时间】:2021-08-1209:58:13【问题描述】:我正在做我的大学项目,我想将图像水平居中对齐,我尝试了很多方法但没有找到解决方案。这是... 查看详情

如何在tailwind-css中水平对齐图像

】如何在tailwind-css中水平对齐图像【英文标题】:HowcanIalignimagehorizontallyintailwind-css【发布时间】:2021-07-0821:30:54【问题描述】:我在使用tailwind-css将图像与网格的子div内的右侧对齐时遇到了困难。我试过float-right、right-0等,但... 查看详情

xml在gridview中水平(可能垂直)居中项目(代码片段)

查看详情

shift+滚动到scrollvieweruwp中水平滚动(代码片段)

我想在键盘上按住SHIFT键同时滚动以水平滚动ScrollViewer。我从here那里了解到PointerWheelChanged事件是我正在寻找的事件。然而,处理它不起作用,因为ScrollViewer在内部处理它,所以我的处理程序永远不会被调用。为了解决这个问题... 查看详情

如何在 Laravel 微风中的 tailwind-css 中水平对齐图像

】如何在Laravel微风中的tailwind-css中水平对齐图像【英文标题】:HowcanIalignimagehorizontallyintailwind-cssinLaravelbreeze【发布时间】:2022-01-1121:51:03【问题描述】:我正在尝试将一个omg与文本对齐,但标签<p>打破了这一行。我... 查看详情

IOS中水平滚动视图问题内的滑块

...试拖动滑块时它不会移动,而是滚动视图本身水平滚动。如何解决这个问题?(在斯威夫特)【问题讨论】:【参考方案1】:Swift3解决方案我也遇到过类似的问题,通过设置解 查看详情

Sencha Touch - 在面板中水平放置而不是垂直放置的标签

】SenchaTouch-在面板中水平放置而不是垂直放置的标签【英文标题】:SenchaTouch-Labelshorizontallyplacedinsteadofverticallyinapanel【发布时间】:2011-12-0515:31:47【问题描述】:我想在垂直布局中放置两个标签、一个文本字段和一个按钮。但是... 查看详情

如何使 UITableView 中的第一列不在 iPhone Objective-C 中水平滚动?

】如何使UITableView中的第一列不在iPhoneObjective-C中水平滚动?【英文标题】:HowtomakefirstcolumninUITableViewnotscrollhorizontallyiniPhoneObjective-C?【发布时间】:2011-07-2814:57:29【问题描述】:我通过向UISrollView添加表格视图并将滚动视图框架... 查看详情

使用jQuery在区域中水平滚动[重复]

】使用jQuery在区域中水平滚动[重复]【英文标题】:ScrollhorizontallyinareawithjQuery[duplicate]【发布时间】:2017-02-1506:01:21【问题描述】:我目前正在做一个项目,我已经介入了一大堆....一些不开心的事情。这个想法很简单我有具有200... 查看详情

使用jQuery在区域中水平滚动[重复]

】使用jQuery在区域中水平滚动[重复]【英文标题】:ScrollhorizontallyinareawithjQuery[duplicate]【发布时间】:2017-02-1506:01:21【问题描述】:我目前正在做一个项目,我已经介入了一大堆....一些不开心的事情。这个想法很简单我有具有200... 查看详情

如何在 PagedGridView 中水平对齐中心的加载图标?

】如何在PagedGridView中水平对齐中心的加载图标?【英文标题】:HowtoalignloadingiconatcenterhorizontallyinPagedGridView?【发布时间】:2021-12-1309:04:01【问题描述】:我正在尝试使用无限滚动在PagedGridView中显示新闻项目,以一次加载有限数... 查看详情