的FrameLayout VS RelativeLayout的叠加层 [英] FrameLayout vs RelativeLayout for overlays

查看:758
本文介绍了的FrameLayout VS RelativeLayout的叠加层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现覆盖(半透明)屏幕,我的应用程序,类似于展示视图东西

I need to implement an overlay (translucent) screen for my app, something similar to Showcase View

我的猜测是使用的FrameLayout此用例,因为它被用于堆叠在彼此顶部的物品。不过,我很惊讶地看到,上述库使用RelativeLayout的。

My guess was to use FrameLayout for this usecase, because it is used to stack items on top of each other. But I was surprised to see that the above library uses RelativeLayout.

我的问题是,当使用的FrameLayout话,如果不是在这样的情况下?缺点是什么,如果我去了的FrameLayout方式?

My question is when to use FrameLayout then, if not in cases like this ? What are the disadvantages if I go the FrameLayout way ?

推荐答案

根据经验,一般规律时,选择的布局是选择导致最少的嵌套布局视图的组合。

A common rule of thumb when choosing layouts is to select the combination that results in the smallest number of nested layout views.

具体到你的问题,RelativeLayout的更大,比更简单的FrameLayout能力更强。因此,对于简单的布局,后者可能是更有效的。但是,如果使用RelativeLayouts,它的添加定位选项可以让你实现在布局视图数量较少的图形用户界面,那么这可能会是一个更好的选择。

Specific to your question, RelativeLayout is larger and more capable than the much simpler FrameLayout. So for simple layouts, the latter is probably more efficient. But if using RelativeLayouts and it's added positioning options allows you to implement your GUI in a smaller number of layout views, then that would likely be a better choice.

下面是一个页面,讨论一些取舍,并演示了一些有用的工具设计你的布局时使用。它主要谈到了RelativeLayout的和的LinearLayout,但也中肯到RelativeLayout的和的FrameLayout之间选择。只要记住的FrameLayout是一个更简单的布局。

Here's a page that discusses some trade-offs and demonstrates some helpful tools to use when designing your layouts. It mostly talks about RelativeLayout and LinearLayout, but is also apropos to your choice between RelativeLayout and Framelayout. Just keep in mind that FrameLayout is an even simpler layout.

这篇关于的FrameLayout VS RelativeLayout的叠加层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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