让我的 Android 应用程序扩展到更大的屏幕
我一遍又一遍地尝试让我的应用程序扩展到更大的屏幕(就像我的新感觉和我的银河标签)。
无论我对 .xml 布局文件做什么,应用程序都会像在小屏幕上一样显示(应用程序周围有黑色的开放空间)。
有没有办法让我的应用程序拉伸以适合屏幕而不重写所有布局或提供新图像?我意识到我可能会有些模糊,但现在我对此表示同意。
谢谢!
I've tried over and over again to get my app to scale to larger screens (like my new sensation, and my galaxy tab).
No matter what I do to my .xml layout files, the app shows up like it's on a small screen (black open space around the app).
Is there anyway to just make my app stretch to fit the screen without rewriting all my layouts, or providing new images? I realize I may get some blur, but I'm ok with that for now.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
确保将其包含在您的 android 清单 xml 中:
其中 x 是目标 sdk 版本,y 是 minSdkVersion。
make sure to include this in your android manifest xml:
where x is the target sdk version and y is the minSdkVersion.
有几种方法。
您需要的是 Android 屏幕兼容模式。
在您的情况下,您必须在清单文件中添加以下内容:
这声明您的应用程序支持所有较大的屏幕尺寸。这会导致系统始终调整您的布局大小以适应屏幕。
一般来说,重要的是不要使用绝对布局。
您应该使用不同的屏幕分辨率、不同的图形文件夹以及不同的 .xml 布局文件(如果需要)。
可能如下所示:
在 XML 布局文件中指定尺寸时,应使用 wrap_content、fill_parent 或 dp 单位。
There are several ways.
That what you need is the Android Screen Compatibility Mode.
In your case you have to add the following in your Manifest file:
This declares that your application supports all larger screen sizes.That has the effect that the system will always resize your layout to fit the screen.
In general is it important that you do not use an Absolute-Layout.
You should use for different screen resolutions, different folders for graphics and if necessary different .xml layout files.
That could like as follows:
You should use wrap_content, fill_parent, or dp units when specifying dimensions in an XML layout file.
您必须放入
清单文件中。 1.5 之前的 api 版本不支持屏幕拉伸,在大尺寸屏幕上,它会保持很小,周围有黑色空间。
You have to put
to your manifest file. Version of api earlier 1.5 doesn`t supports streching of the screen and on the big-size screens it will remains small with black space around.
我创建了一个工具,允许您缩放/调整平板电脑和小屏幕设备的布局,并在此处发表了一篇关于它的博客文章:http://onemanmobile.blogspot.com/2012/04/how-to-scale-your-android-layouts-to.html
基本上,如果您希望您的应用程序适合所有设备和平板电脑,那么以 dp 单位定义布局是不够的,因为有四种不同的“密度桶”。该工具将允许您的布局转换为适合这些密度桶。
我希望博客、工具和答案能够帮助其他人,我知道通过按一下按钮让我的应用程序在平板电脑上运行感觉很好。
I created a tool that allows you to scale/adjust your layouts for tablets and small screen devices and made a blog post about it here: http://onemanmobile.blogspot.com/2012/04/how-to-scale-your-android-layouts-to.html
Basically, defining your layouts in dp units is not enough if you want your app to fit on all devices and tablets, since there's four different "density-buckets". This tool will allow your layouts to be converted into fitting these density buckets.
I hope the blog, tool and answer will help others, I know it felt good to have my app work on a tablet with the press of a button.
它解决了我的问题。
It solved my problem.