简体   繁体   English

设计手机和平板电脑的布局

[英]Designing layouts for phones and tablets

Okay i am familiar with this site and what it says 好吧,我熟悉这个网站及其内容

http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/guide/practices/screens_support.html

But im still having a problem. 但是即时通讯仍然有问题。

I am designing layouts for phones and tablets from gingerbread to jelly bean. 我正在设计从姜饼到软糖的手机和平板电脑的布局。

I had started with a basic layout folder and designed everything for a galaxy nexus phone. 我从一个基本的布局文件夹开始,然后为银河系手机设计了所有东西。 now im going back and adding tablets. 现在我要回去并添加平板电脑。 one question here is should i use layout-xlarge/layout-large or layout-sw600dp/layout-sw720dp? 这里的一个问题是我应该使用layout-xlarge / layout-large还是layout-sw600dp / layout-sw720dp吗? im guessing the smallest width is what i should be using. 我猜最小的宽度是我应该使用的。

But thats not the issue. 但这不是问题。 This issue is im trying to do that layous for Galaxy Nexus (720x1280) and Nexus S (480x800) These are much different yet eclipse doesn't seem to let me differentiate. 这个问题是我试图为Galaxy Nexus(720x1280)和Nexus S(480x800)做的事情,这两者之间有很大的不同,但日食似乎并不能使我与众不同。

So i just want to be clear on what i should be doing to do this right. 所以我只想清楚我应该做些什么来正确地做到这一点。 is this what i should have to cover the devices i want to? 这是我覆盖我想要的设备所必需的吗?

layout-hdpi layout-xhdpi layout-sw600dp (instead of layout-large) layout-sw720dp (instead of layout-xlarge) layout-hdpi layout-xhdpi layout-sw600dp(而不是layout-large)layout-sw720dp(而不是layout-xlarge)

will doing those layout-hdpi and layout-xhdpi separate the layouts for a Nexus S and Galaxy Nexus? 那些layout-hdpi和layout-xhdpi是否将Nexus S和Galaxy Nexus的布局分开?

First, the layout-sw are based on dp , Density-independent pixels, rather than pixels. 首先,layout-sw基于dp (与密度无关的像素),而不是像素。 You can think of dp as 'actual size' pixels ie, 1dp is the same physical size no matter what device is being used. 您可以将dp视为“实际尺寸”像素,即无论使用哪种设备,1dp都是相同的物理尺寸。

Therefore the Galaxy Nexus, which has a 720x1280 pixel screen is only 360x640 dp resolution and there is no overlap between a phone and the higher sw600+ folders. 因此,具有720x1280像素屏幕的Galaxy Nexus的分辨率仅为360x640 dp,并且手机与更高的sw600 +文件夹之间没有重叠。

The large/xlarge buckets will continue to work on all tablets, but if you need finer grained support or alright only using tablet layouts on Android 3.2+ devices, then you only need the sw--dp folders. 大/超大存储桶将继续在所有平板电脑上运行,但是如果您需要更细粒度的支持,或者仅在Android 3.2+设备上使用平板电脑布局,则只需要sw-dp文件夹。 You can also use both without copy/pasting your XML by using a reference file, as detailed in the below blog post. 您还可以使用参考文件来使用这两种方法,而无需复制/粘贴XML,如下面的博客文章中所述。

More details on how to support multiple screens can be found in Supporting Multiple Screens guide and some of the reasoning behind why you'd want to use the new sw---dp buckets can be found on the Android Developers blog post announcing the feature . 有关如何支持多屏幕的更多详细信息,请参见《 支持多屏幕》指南,而您想使用新的sw --- dp存储桶的背后原因可以在宣布该功能的Android开发者博客中找到。

Just use layout-large and layout-xlarge . 只需使用layout-largelayout-xlarge When you're developing the layouts and want to know what it looks like on a certain device, just change the view and it will pull the appropriate XML from the correct folder. 当您开发布局并想知道其在特定设备上的外观时,只需更改视图,它将从正确的文件夹中提取适当的XML。

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

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