Android:向下缩放固定布局
我想扩展我的 Android 应用程序,基本上我使用 AbsoluteLayout 开发它以用于 800x480 显示。这对于我的应用程序是必需的,我无法更改它。
现在的问题是: 当我在模拟器中启动我的应用程序时,按钮消失并且图像非常大。我以为android默认会以固定大小缩小应用程序,但它不起作用。我已经尝试过操纵清单,但这没有用。
我使用 ImageView 组件来显示图形。 瞄准 Android 2.1
干杯 菲利克斯
i want to scale my android application, basically i developed it for 800x480 display with a AbsoluteLayout. This is necessary for my Application, i can't change it.
Now the Problem:
When i start my app in the Emulator the buttons disappear and the images are extremly large. I thought android would scale applications with a fixed size down by default, but it does not work. I already tried to manipulate the manifest but this did not work.
I use a ImageView component for graphics.
Targeting Android 2.1
Cheers
Felix
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用AbsoluteLayout肯定不太理想。但是,如果您只想继续使用它,则应该将所有坐标和大小的单位从 px(像素)切换为 dp(密度独立像素)。首先,您必须将所有现有坐标缩放 2/3,因为在您的布局目标密度 (hdpi) 下 1 dp = 1.5px。
您需要明确指定所有图像和布局的尺寸。例如,如果您有一个宽度为 30px、高度为 120px 的按钮,那么它将变为宽度为 20dp、高度为 80dp。
当然,图像在较小的 (mdpi) 屏幕上看起来不太好,因为它们将缩放至 2/3 尺寸。此外,有些设备固定为横向模式,您肯定会遇到布局问题。所以它并不漂亮,但它可能会让你越过终点线,具体取决于你的要求。
It is definitely not ideal to use AbsoluteLayout. But, if you want to just push through with it, you should switch the units of all your co-ordinates and sizes away from px (pixels) to dp (density independent pixels). You will have to scale all of your existing co-ordinates by a factor of 2/3 to start, since 1 dp = 1.5px at the density that your layout targets (hdpi).
You will need to explicitly specify the sizes of all your images and layouts. If, for example, you had a button that was 30px wide and 120px tall, then it will become 20dp wide and 80dp tall.
Of course, the images won't look great on smaller (mdpi) screens, since they will be scaled to 2/3 size. Also, some devices are fixed to landscape mode, where you will definitely encounter layout problems. So it's not pretty, but it may get you over the finish line, depending on your requirements.