我制作了一款适用于平板电脑和手机的应用程序。但正如我们所知,我们应该为平板电脑提供不同的布局(例如更大的字体和图像等)。
我的问题是如何提供布局,以便它们仅由平板电脑而非手机选择。
示例:如果我提供 xhdpi 或 hdpi 布局,将它们视为平板电脑,那么它可能会被使用相同配置的某些设备选择。
那么如何确定当前设备是平板电脑还是手机并为其提供特定的布局呢?
最佳答案
My question is how to provide the layouts such that they are only picked by tablets and not phones.
要么使用经典的屏幕尺寸桶(例如,res/layout-large/
),要么使用-swNNNdp
(例如,)想出你自己的桶res/layout-sw600dp/
用于在最短宽度为 600dp 或更高的设备上使用的资源。
文档中对此进行了解释 here , here , here ,也许还有其他一些地方。
Example: If i provide xhdpi or hdpi layout thinking of these as tablet then it may be picked by some device also which is using this same configuration.
-xhdpi
和 -hdpi
是屏幕密度,与屏幕尺寸没有直接关系。
关于Android 手机和平板电脑用户界面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15590815/