布局层?Z轴? [英] Layout Layers? Z-Axis?

查看:17
本文介绍了布局层?Z轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过许多在其布局中使用分层的应用程序.当我说分层时,我指的是相对于用户视图的 z 轴上的层.Craigslist 通知应用就是这样的一个应用,其中在 listView 的顶部有一个靠近底部的加号,允许用户访问添加额外的列表项.

I have seen numerous applications that use layering in their layouts. When I speak of layering I am referring to layers in the z-axis relative to the view of the user. One such app is the Craigslist Notification app where on top of the listView there is a plus sign near the bottom to allow user access to adding an additional list item.

就我而言,我成功地使用 GestureListener 来翻页.效果很好,但如果用户当前所在的页面前后有页面,我想在页面边缘叠加一个透明的左右箭头 png.

In my case, I am successfully using a GestureListener to turn pages. Works well, but I would like to superimpose a transparent right and left arrow png on the edges of the pages if there are pages back or forward of the one the user is currently on.

我已经搜索过,但不太确定如何让 Layout 的 2 个元素同时占用相同的空间.在这种情况下,您拥有页面(布局)的内容,以及该布局(z 轴)顶部的某些内容.

I have searched, but not quite sure how to have 2 elements of a Layout consume the same space simultaneously. In this case you have the content of the page (layout), and the need for something on top of (z-axis) of that layout.

有人能指出我正确的方向吗?

Can someone point me in the right direction?

推荐答案

尝试使用 FrameLayout.

Try using FrameLayout.

FrameLayout 总是将一个东西放在另一个上面,并且总是参考左上角,因此您需要在 FrameLayout 内使用单独的布局来将您的对象放置在屏幕上您想要的位置.

FrameLayout always places things one on top of the other and always in reference to the upper lefthand corner, so you'll need to use separate layouts inside of FrameLayout to place your objects where you want the on the screen.

请记住,android 会按照列表中的顺序将内容放入您的布局中,因此请将您想要的布局底部的对象放在靠近显示器顶部的位置.

Remember that android will put things into your layout in the order that they are list, so place objects at the bottom of the layout that you want near the top of your display.

这是一个简单的例子(不要忘记将适当的 xml 头数据添加到顶部节点):

Here's a quick example (don't forget to add proper xml header data to the top node):

<FrameLayout>
  <RelativeLayout>
    <!--  Place the objects you want on the bottom here -->
  </RelativeLayout>


  <RelativeLayout>
    <!--  Place the objects you want on the top here -->
  </RelativeLayout>
</FrameLayout>

这篇关于布局层?Z轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆