我有一个普通的hdpi-480x800布局,其中包括按钮和类似的图形。 我主要使用RelativeLayout,因为它建议更好的性能,并且我的元素从左上角相对于彼此定位。 根据screens_support.html,该组可能还包括600x1024分辨率设备。 因此,当我在LG L9(540x960)上测试应用程序时,它也属于normal-xhdpi,它看起来很糟糕 - 看起来使用像素和dp之间没有区别。 这是一个代码示例:
<Button android:id="@+id/fb_post_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/share_fb_m_l" android:layout_marginTop="@dimen/share_fb_m_t" android:background="@drawable/fb_btn" />有帮助吗? 我可能做错了什么?
谢谢。
I have a normal-hdpi-480x800 layout, which includes buttons and similar graphics. I mostly use RelativeLayout, since it's recommended for better performance, and position my elements from the upper left bound relatively to each other. According to screens_support.html this group might also include 600x1024 resolution devices. So, when I test the application on LG L9 (540x960), which also falls into normal-xhdpi, it looks horrible - it seems there's no difference between using pixels and dp. Here's an example of code:
<Button android:id="@+id/fb_post_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/share_fb_m_l" android:layout_marginTop="@dimen/share_fb_m_t" android:background="@drawable/fb_btn" />Any help ? What I might be doing wrong ?
Thanks.
最满意答案
如果您需要根据屏幕密度更多地控制按钮大小,只需在文件夹values-ldpdi , values-mdpi , values-hdpi , values-xhdpi指定不同的尺寸。 喜欢这个:
<resources> <dimen name="share_fb_m_l">47dp</dimen> <dimen name="share_fb_m_t">57dp</dimen> </resources>更新 :您可以更好地控制此:
为不同的屏幕分辨率和密度指定多个不同的图像。 为此,请阅读支持多个屏幕。 如果您需要更高精度的图像缩放和质量,您可以使用swdp的屏幕属性的基本大小 - 您可以指定应使用图像的屏幕的最小宽度。 这是资源文件夹的限定符名称。
将尺寸放在这些文件夹values-sw540dp , values-sw540dp , values-sw600dp - 这些应作为子文件夹以进行更多控制。
Just specify different dimensions in folders values-ldpdi, values-mdpi, values-hdpi, values-xhdpi if you need more control over button sizes according to screen density. Like this:
<resources> <dimen name="share_fb_m_l">47dp</dimen> <dimen name="share_fb_m_t">57dp</dimen> </resources>Update: You can get more control over this:
Specify multiple different images for different screen resolutions and densities. To do so read supporting multiple screens. If you need even more precision in image scaling and quality you can use the fundamental size of screen attribute which is swdp - you can specify the smallest width of the screen where your image should be used. This is a qualifier name for a resource folder.
Place your dimensions in these folders values-sw540dp, values-sw540dp, values-sw600dp - these should serve as subfolders for more control.
更多推荐
发布评论