如何解决Android屏幕尺寸适应不同移动设备的问题?
我正在小屏幕手机上测试 Android 应用程序。如果我像其他横向手机一样使用三星平板电脑来测试我的 Android 应用程序,内容会稍微移动。 Android中如何解决屏幕分辨率问题?
I am testing the Android application in a small screen mobile. If I use Samsung tablets like other landscape mobile to test my android application the contents are moved slightly. How do I solve the screen resolution in Android?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在manifest.xml中使用它
use this in manifest.xml
您可以根据屏幕尺寸(四种不同的屏幕尺寸)创建多个布局将它们放在 res 下的不同文件夹中,如下
所示您还需要在 menifest 文件中添加以下行
有关更多信息 检查此链接
you can create multiple layouts as per screen size (four different screen size) & put them in different folders under res like below
Also you need to add below lines in menifest file
For more information check this link
尽量不要用 px 来硬编码。尝试使用 fill_parent wrap_content。在非常必要的情况下,为您的布局创建单独的文件夹,如布局、布局土地、布局小、布局小土地、布局大等。将布局放置在这些文件夹中并更改布局设置。其余的将由 Android 操作系统负责。
Try not to hardcode things in terms of px. Try using fill_parent wrap_content. Under very necessary circumstances,create separate folders for your layout as in layout,layout-land,layout-small,layout-small-land,layout-large etc. Place your layout in these folders and change your layout settings. Rest will be taken care by Android OS.
我认为你应该使用java代码获取屏幕分辨率,然后使用给定的分辨率在
activity
的oncreate()方法中动态设置小部件大小。I think you shuold get the screen resoloution in using java code and then set the widgets size by dynamically in
oncreate()
method ofactivity
by using the given resolution.