gpt4 book ai didi

blackberry - 如何修复 BlackBerry 中垂直和纵向屏幕的对齐方式?

转载 作者:行者123 更新时间:2023-12-02 06:41:01 25 4
gpt4 key购买 nike

我想做一个即使屏幕改变为纵向或横向也不会改变 UI 的应用程序。如何做到这一点?

最佳答案

我在我的一个库类中创建了一个静态方法:

public static void disableOrientationChange()
{
// force app to use only portrait mode
int directions = Display.DIRECTION_NORTH;
UiEngineInstance engineInstance = Ui.getUiEngineInstance();
if (engineInstance != null)
{
engineInstance.setAcceptableDirections(directions);
}
}

诀窍 是此代码仅适用于运行后创建的屏幕。因此,您必须在显示第一个屏幕之前运行代码。

我从 Application.main(String args) 方法调用此方法,就在调用 enterEventDispatcher() 之前。

public static void main(String[] args)
{
MyApp app = new MyApp();

/*
* BlackBerry OS 5.0.0
* Disable screen orientation changes
*/
ScreenUtils.disableOrientationChange();

// enters the event processing loop thread if required
if (!app.isHandlingEvents())
{
app.enterEventDispatcher();
}
}

关于blackberry - 如何修复 BlackBerry 中垂直和纵向屏幕的对齐方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8076853/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com