更新时间:2023-01-03 21:21:55
您可以通过为每个非标准屏幕尺寸创建布局做了,
这里 RES /布局/ my_layout.xml //适用于布局进行正常的屏幕尺寸(默认)
RES /布局小/ my_layout.xml //适用于布局屏幕尺寸小
RES /布局大/ my_layout.xml //适用于布局大尺寸屏幕
RES /布局XLARGE / my_layout.xml //适用于布局超大屏幕尺寸
RES /布局XLARGE土地/ my_layout.xml //适用于布局横向特大型RES /绘制-MDPI / my_icon.png //适用位图中密度
RES /绘,华电国际/ my_icon.png //适用位图高密度
RES /绘制-xhdpi / my_icon.png //适用位图特高密度
这意味着你应该创建命名为(布局,布局小,布局大,布局XLARGE,布局XLARGE土地)在res文件夹中。子目录p>
不是创建为每一个有相同名称的主XML。
I am wondering how to get different XML layout files to be read depending of density of the screen.
Now when I enter a layout file and set to so that it has a couple of buttons and have them set to a specific position, the position changes when I change to another screen density in the emulator. This is what should be happening what i understand- but How do I get the program to use different layouts depending of densities?
I have been reading on android dev. page on how to develop for different screens, but I didn't get the examples which were there.
I have been using dp/dip on sizes so no need to suggest that =)
you can do it by creating a layout for each standart screen sizes,
you can find here how to do it.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
it means you should create sub-directory named as ("layout", "layout-small","layout-large","layout-xlarge","layout-xlarge-land") in res folder.
than create a main xml for each one with the same name.