黑莓编程上的自动旋转
我为 Blackberry Storm 编写代码。当我的应用程序处于水平显示(480x360)时,它可以工作。但是当黑莓倾斜到垂直(360x480)时,图片就会被切断。所以我想问如何设置以便在旋转时也调整图片大小?有什么方法可以检查黑莓手机是否再次水平或垂直显示?
谢谢。
I make code to Blackberry Storm. When my application in horizontal display (480x360), it's work. But when the Blackberry tilt into Vertical (360x480), the picture is cut off. So I was asking how to set up so that at the time of rotation, also resize the picture? is there any method to check if BlackBerry again horizontal or vertical display?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有两件事,要么您将锁定屏幕方向,要么您将在应用程序中提供支持。
代码示例:检索屏幕方向
代码示例:在 BlackBerry API 应用程序中强制纵向视图
如果您想要在方向更改时处理图像和其他图形设置,那么您可以执行以下操作:更改您的代码后。
在 MainScreen 子类中重写子布局方法。
受保护的无效子布局(int arg0,int arg1){
// 做所有的事情
super.sublayout(arg0, arg1);
}
检查方向变化,重新排列 UI。对于此类事情,建议使用相对布局。
希望,这可以帮助你。有关详细信息,请访问 Specifying_display_direction_of_screen
编辑: 覆盖 sublayout()然后编写特定于方向的代码
编辑 2:
由于 UI 事件锁定,您会出错,现在您会这样做对您的代码进行以下更改。
Here are two things, either you will lock screen orientation or you will support in your application.
Code sample: Retrieving screen orientation
Code sample: Forcing portrait view in a BlackBerry API application
You you want to handle the images and other graphics setup on orientation change then you can do the following changes in your code.
Override the sublayout method, in your MainScreen subclass.
protected void sublayout(int arg0, int arg1) {
// do all the
super.sublayout(arg0, arg1);
}
Check for the orientation changes, rearrange the UI. Usages of relative layout is recommended for such things.
Hope, this might help you out. For more info visit Specifying_display_direction_of_screen
Edit: override sublayout() and then write the code specific to orientation
Edit 2:
you were going wrong because of UI event lock, now you do the following changes to your code.
好吧,我之前遇到过这个问题并解决了。解决方案不是“强制黑莓屏幕不旋转”。我以前做过这个,这很烦人。解决这个问题的方法是重写主屏幕的 subLayout 方法以及主屏幕中包含的所有管理器。当发生旋转时总是调用此方法。
您的代码将如下所示:
Well I faced this problem before and solved it. The solution is not to "oblige the blackberry screen not to rotate". I made this before and it is annoying. Well the solution to this is override the subLayout method of the main screen and all the managers included in the main screen. This method is always called when a rotation occurs.
Your code will looks like follows: