如何在布局编辑器中模拟沉浸模式 [英] How to emulate immersive mode in layout editor

查看:142
本文介绍了如何在布局编辑器中模拟沉浸模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在布局编辑器中全屏查看我的布局.我正在使用eclipse插件.

I'd like to view my layouts in full screen in the layout editor. I'm using the eclipse plugin.

我已经通过选择组合中的*NoActionBar主题隐藏了ActionBar,但是导航栏是一个不同的故事. AFAIK只能使用代码中的标志将其隐藏.

I've already hidden the ActionBar by selecting a *NoActionBar theme in the combo, but the navigation bar is a different story. AFAIK it can only be hidden using flags in code.

我需要对活动xml文件进行连续调整,并且在并非直接不可能的情况下(在我的PC无法运行全高清模拟器的情况下,在模拟器中对其进行测试是一个真正的痛苦,并且我需要对另一台SSH进行SSH)机器).不用说我没有真正的设备.

I need to make continuous tweaks in the activity xml files, and testing it in the emulator is a real pain, when not directly impossible (my PC can't run a full HD emulator, and I'd need to SSH another machine). Needless to say I dont have the real device.

有没有办法在真正的全屏模式下查看布局?

Is there a way of viewing layouts in true full screen?

推荐答案

不幸的是,似乎没有办法.这样的基本功能应该早就添加了,恕我直言,这比我们在Google IO上展示的精美东西具有更高的优先级. 但是无论如何,布局编辑器通常会中断或引发异常.我不确定这是否仅在Eclipse中发生,因为我还没有使用Android Studio.

Unfortunately seems there's no way of doing this. Such a basic feature should have been added long ago, IMHO this has higher priority than the fancy things we're shown at Google IOs. But anyway the layout editor usually breaks or throws exceptions. I'm not sure if this happens only in eclipse, as I'm not using Android Studio yet.

解决方法

  • 在模拟器中测试.如果要在没有Intel VT-x扩展的CPU中模拟大屏幕,则速度较慢,这不是一种选择(使用Mac的用户很幸运)
  • 由于无法在布局编辑器中消除黑条,因此可以使用容纳条的额外屏幕空间来创建新的虚拟设备定义,以使可用屏幕区域具有准确的大小.您需要模拟的设备.

示例:
以模拟5英寸高清屏幕,我们将创建以下设备定义:

Example:
to emulate a 5 inch HD screen we would have created this device definition:

  • 屏幕尺寸(英寸):5.0
  • 分辨率(px):1920 x 1080

如果我们使用该定义创建一个AVD并在横向模式下的布局编辑器中对其进行预览,则会在右侧看到可怕的黑条,这会占用屏幕空间,并无法正确显示宽度为的视图依赖于重力. 为了能够查看1920x1080px的自由区域,我们可以进行截屏并使用图像编辑器进行测量,以衡量黑条占用的宽度.在我的情况下,这是6.22%,因此要有1920像素的可用宽度,我们需要多出约120像素,总计为2040像素.

If we create an AVD with this definition and preview it in the layout editor in landscape mode, we'll see the dreaded black bar in the right side, which is eating up screen space and prevents correct visualization of views whose width is gravity dependent. To be able to view a free area of 1920x1080px, we can make a screen capture and measure with an image editor how much width is the black bar taking. In my case it was a 6.22%, so to have 1920px free width we need about 120 extra px, that sums a total of 2040px.

我们现在知道我们的设备必须是2040x1080,我们可以使用勾股定理以英寸为单位计算对角线.在我们的示例中,新设备定义为:

We now know our device must be 2040x1080, and we can use the Pythagorean theorem to calculate the diagonal in inches. In our example the new device definition would be:

  • 屏幕尺寸(英寸):5.24
  • 分辨率(px):2040 x 1080

这为我们提供了一个自由区域,其比例为w/h = 1.77,大约为16:9.

This gives us a free area whose proportions are w/h=1.77, which is roughly 16:9.

这篇关于如何在布局编辑器中模拟沉浸模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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