Android Canvas屏幕分辨率问题

发布于 2024-11-30 22:31:19 字数 384 浏览 6 评论 0原文

在我的应用程序中有一个画布,当两部手机通过蓝牙连接时,我们可以实时共享绘图。

问题是当不同屏幕尺寸的手机(例如:LG Optimus 和 HTC Incredible S)通过蓝牙连接时, 画布的缩放变得混乱,HTC 中的画布只有一小部分相当于 LG 的画布。

仅当我在清单文件中使用以下内容以实现市场兼容性时,才会发生这种情况

<uses-sdk android:minSdkVersion="7"></uses-sdk>

如果未定义上述内容,它将实现适当的宽度尺寸映射和几乎完美的高度缩放。

我不明白为什么会发生这种情况。 有没有其他方法可以映射画布,以便我们可以在从手机到平板电脑的不同屏幕尺寸之间进行缩放。

In my application there is a canvas, when two phones are connected via bluetooth we can share the drawing in real time.

Problem is when phones of different screen size ex: LG Optimus and HTC Incredible S are get connected via bluetooth,
The scaling of the canvas goes haywire only a small part of the canvas in HTC is equivalent to the LGs canvas.

This happens only when i use the following in the manifest file for market compatibility

<uses-sdk android:minSdkVersion="7"></uses-sdk>

If the above is not defined it achieves a proper width size mapping and almost perfect height scaling.

I am not getting why it is happening.
IS there any other way we can map the canvas in such a way that we can scale between different screen sizes varying from phones to tablets.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明月夜 2024-12-07 22:31:19

您可以使用以下内容:

DisplayMetrics metrics = getBaseContext().getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;

You could use the following:

DisplayMetrics metrics = getBaseContext().getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文