处理同一配置组中的不同分辨率(Handling different resolutions within the same configuration group)

编程入门 行业动态 更新时间:2024-10-18 20:19:57
处理同一配置组中的不同分辨率(Handling different resolutions within the same configuration group)

我有一个普通的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.

更多推荐

本文发布于:2023-07-16 12:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1128613.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组中   分辨率   Handling   group   configuration

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!