简体   繁体   English

Android预览与模拟器布局大小

[英]Android Preview vs Emulator Layout Size

Folks, 伙计们,

I cant design my android screens and see it on my emulator somehow the resolution, zoom (whatever) in the emulator is big and my layout is messed up. 我无法设计自己的android屏幕,并在模拟器上以某种方式看到它,但模拟器中的分辨率,缩放(无论如何)都很大,而且布局混乱。

The whole layout is inside a FrameLayout, the paragraph text in the emulator pic is inside a RelativeLayout, which is set to GONE after users upload rating, then LinearLayout shows up with the overall rating bar in the some place where the RelativeLayout was. 整个布局在FrameLayout内,模拟器图片中的段落文本在RelativeLayout内,在用户上传评级后设置为GONE,然后LinearLayout在RelativeLayout所在的某个地方显示整体评级栏。

My question is why is this happening since in the preview it seems perfect and on the emulator it seems all messed. 我的问题是为什么会发生这种情况,因为在预览中它看起来很完美,而且在模拟器上它似乎都搞砸了。

Please see the screenshots: 请查看屏幕截图:

Android Studio Preview: Android Studio预览版: 一切都适合

Genymotion Emulator Genymotion模拟器 用户提交评级后会显示第一个评级栏,在预览时它很适合屏幕

It is really hard to determine what exactly is wrong without seeing your xml markup. 在没有看到您的xml标记的情况下,很难确定到底出了什么问题。

Possible Reasons 可能的原因

  1. You gave your layouts some sort of fixed size, and therefore it appears to be fine on your markup, but whatever you are emulating on Genymotion is using a different ratio. 你给你的布局提供了某种固定的大小,因此它在你的标记上显得很好,但无论你在Genymotion上模仿的是使用不同的比例。
  2. When you do a View.GONE, you say you are replacing a RelativeLayout with a LinearLayout. 当您执行View.GONE时,您说您正在用LinearLayout替换RelativeLayout。 Well, do you make sure that the layout that is replaced is layoutAbove whatever that frame layout below it is? 那么,你确定被替换的布局是layoutAbove它下面的框架布局是什么?
  3. Some layout just has some attribute, like an alignment issue, that is causing this. 某些布局只有一些属性,如对齐问题,导致这种情况。

Trace your steps backwards, removing one thing at a time. 向后追踪你的步骤,一次删除一件事。 Get it to work with that view gone first, then add it and manipulate it after. 让它首先使用该视图,然后添加它并在之后操作它。

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

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