简体   繁体   English

Android:小部件和布局

[英]Android: widget and layout

How can I create a widget layout compatible with all display and any density ? 如何创建与所有显示和任何密度兼容的小部件布局? Thanks 谢谢

That isn't really possible using one file. 使用一个文件实际上是不可能的。

The best option to use is to create one layout, then create one style file. 最好的选择是创建一个布局,然后创建一个样式文件。 Then in the style place styles for the elements in your layout. 然后在样式中,为布局中的元素放置样式。 Then you can create a dimens file in layout-small, layout-normal, layout-large, layout-xlarge. 然后,您可以在layout-small,layout-normal,layout-large,layout-xlarge中创建一个dimens文件。 Here you can place display size related dimensions in density independant measurements, such as dp and sp. 在这里,您可以将与显示尺寸相关的尺寸放置在密度无关的测量值中,例如dp和sp。

Then of course, you will need to do the whole song and dance with creating drawables for all various densities. 然后,当然,您需要通过为所有密度创建绘图来完成整个歌舞。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM