安卓:要使用的UI元素大小单位(如DP不工作)要使、元素、大小、单位

2023-09-07 13:18:22 作者:穿着校服追鹿晗i

即时通讯开发一个应用程序将是对三星Galaxy SII和三星Galaxy Tab 7.7仅使用。 所有的UI元素的尺寸在所推荐的Andr​​oid开发者指南DP的已被指定。据我的理解是,这将确保元素保持相同的感知大小在不同的屏幕上的用户。 我的问题是,虽然所有的用户界面元素显示在7.7英寸设备(围绕他们的样子就SII 2/3)上要小得多。

Im developing an App which is going to be used on Samsung Galaxy SII and Samsung Galaxy tab 7.7 ONLY. The sizes of all the UI elements have been specified in dp's as recommended by the Android developer guide. As I understood it, this would ensure that elements maintain the same perceived size to the user across different screens. My problem though is that all UI elements appear much smaller on the 7.7 inch device (around 2/3 of what they look like on the SII).

我想他们是相同大小的平板电脑上,或甚至更大。 我已经测试了不同的单元格式,用于测量尺寸,当我英寸或毫米指定他们,他们具有相同的尺寸,并在PX的时候都更大的平板电脑。

I would like them to be of equal size on the tablet, or perhaps even bigger. I have tested the different unit formats for measuring size, and when i specify them in inch or mm they have the same size, and when in px they are bigger on the tablet..

这是不是真的使用任何的3个单位正确的方法,如果是这样,那么为什么Android的建议DP的??

But is it really the correct approach to use any of those 3 units, and if so, then why do Android recommend dp's??

我希望有人在那里可以澄清这一点:)

I hope anyone out there can clarify this :)

推荐答案

Dp的工作在大多数情况下使用,但如果我是你,我会指定不同的布局文件夹,在这种情况下,布局XLARGE /为您的7.7英寸设备和布局正常/为你的GALAXY SII。

Dp works to use in most cases but if I were you i would specify different layout folders, in this case a layout-xlarge/ for your 7.7 inch device and a layout-normal/ for your Galaxy SII.

然后复制您的布局XML文件,把这些文件夹中,并指定位置/大小根据将使用它的设备。

Then duplicate your layout xml files and put in these folders, and specify position/sizes according to the device that will use it.

从这里信息: http://developer.android.com/guide/做法/ screens_support.html#支持