简体   繁体   English

如何在android中实现此布局?

[英]How do I achieve this layout in android?

I'm in the process of building an interactive presentation on an android tablet. 我正在在Android平板电脑上构建交互式演示文稿。 I've going through the basic tutorials to try and get an understanding of the tools available. 我已经阅读了基础教程,以尝试了解可用的工具。 I'm now at the stage where I'd like to create a dummy application but I'm unsure about the best approach for this. 我现在正在创建虚拟应用程序的阶段,但是我不确定最好的方法。 I've attached the image below to give you an idea of what I'm looking to do: 我已附上以下图片,以使您大致了解我要做什么:

在此处输入图片说明

What I'm looking to do is have a static navigation on the right. 我想要做的是在右侧有一个静态导航。 When you select the options on there, they'll switch out the content on the left, by rotating the panel and having the new content on the flip side. 当您选择那里的选项时,它们将通过旋转面板并将新内容放在反面而在左侧切出内容。 The middle pane will be a collection of images that can be swiped through. 中间窗格将是可以滑动浏览的图像的集合。

So far I've been playing around with the ViewPager class and this seems to be ideal for allowing me to quickly swipe between images. 到目前为止,我一直在玩ViewPager类,这对于让我快速在图像之间滑动非常理想。 The only enhancement I'd like to make is to allow the user the ability to pinch zoom on these images, but only the images get zoomed and not the entire screen. 我唯一想做的改进就是让用户可以对这些图像进行缩放,但是只有图像被缩放而不是整个屏幕。 Is this possible? 这可能吗?

Secondly, coming from a web background, I'm trying to figure out what the equivalent of a div is for android? 其次,我来自网络背景,试图找出相当于div的android吗? Ideally I'd like a panel on the left with multiple textviews/imageviews depending on the content but I'm not sure how to achieve this with the android API. 理想情况下,我希望在左侧的面板上根据内容具有多个textviews / imageviews,但我不确定如何使用android API实现此目的。 Is it a case of creating one big fragment and having multiple nested views within this? 是否需要创建一个大片段并在其中包含多个嵌套视图?

I also wonder how I can achieve the rotating effect on this panel. 我也想知道如何在此面板上实现旋转效果。 I've managed to achieve the effect in a dummy app using: 我设法使用以下方法在虚拟应用程序中实现了效果:

tv.animate().rotationYBy(180).setDuration(2000);

But what I don't know how to do is to get the content changed when a new item is selected. 但是我不知道该怎么做,就是在选择新项目时更改内容。 I'm thinking that maybe I'll dynamically remove the current fragment, add the new fragment and quickly rotate it on menu item select. 我在想,也许我会动态删除当前片段,添加新片段,并在选择菜单项时快速旋转它。 Is this a sensible approach? 这是明智的做法吗?

I apologise if these are daft questions, I'm just having a hard time understanding how I can achieve these things within android. 如果这些是愚蠢的问题,我深感抱歉,我只是很难理解如何在android中实现这些目标。 Any suggestions? 有什么建议么?

Thanks 谢谢

I can make your life little bit easier and say that there is no kind of default layouts you can simply use to implement a such thing. 我可以使您的生活更轻松一些,并说没有一种默认布局可以简单地用于实现这种功能。 Implementation of a such layout will be different from developer to developer, I think complete answer you will not receive because it is complex and require writing actual code too. 此类布局的实现因开发人员而异,我认为您不会收到完整的答案,因为它很复杂,并且也需要编写实际代码。 From me, I can try to assist you and I'm sure everybody else will too. 从我这里,我可以尝试为您提供帮助,而且我相信其他所有人也都会为您提供帮助。

You definetly should read about Fragments . 您肯定应该阅读有关Fragments的信息

As for the zoom you can create a custom ImageView. 至于缩放,您可以创建一个自定义ImageView。 ( Like This ) 像这样

The equivalent of div in android are the layout containers, such as LinearLayout , RelativeLayout , FrameLayout , etc... Read this for more info about layouts. 在android中,相当于div的是布局容器,例如LinearLayoutRelativeLayoutFrameLayout等。阅读此内容可获得有关布局的更多信息。

I have seen 1 example in ActionBarSherlock library sample ( Styled ) in which 1 fragment is rotated 180 degree when a Tab is pressed. 我在ActionBarSherlock库示例( 样式为 )中看到了1个示例,其中当按Tab时将1个片段旋转180度。 Just same as you want. 就像你想要的一样。 see link below. 请参阅下面的链接。

Have a look at Android Fragments and following two libraries, you can get every thing required from these libraries, see sample codes. 看看Android Fragments,然后看看下面的两个库,您可以从这些库中获取所需的一切,请参阅示例代码。

  1. ActionBarSherlock ActionBarSherlock
  2. Android-ViewPagerIndicator Android-ViewPagerIndicator

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM