禁用滚动到焦点按钮
Disable scroll to focused button
您好,屏幕底部有两个按钮,每次我打开这个屏幕时,视图都会滚动到底部以显示那些获得焦点的按钮,是否有任何方法可以禁用此行为并首先显示顶部屏幕?
您必须在屏幕顶部添加一个可聚焦的区域。这取决于您如何实现这一点,但通常您可以将 NullField
作为屏幕的第一个视图。
NullField
应该为您接收初始焦点,但请注意,用户仍然可以像使用任何其他视图一样滚动回到它。所以看起来你的重点可能是 "lost",具体取决于你的设计外观。
public class MyScreen extends MainScreen
{
public MyScreen()
{
super(VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL);
add(new NullField()); // Nullfield to be initially focused
// Screen content with focusable button at the bottom
add(new LabelField("Label"));
ButtonField button = new ButtonField("Button");
button.setMargin(1000, 0, 0, 0);
add(button);
}
}
您好,屏幕底部有两个按钮,每次我打开这个屏幕时,视图都会滚动到底部以显示那些获得焦点的按钮,是否有任何方法可以禁用此行为并首先显示顶部屏幕?
您必须在屏幕顶部添加一个可聚焦的区域。这取决于您如何实现这一点,但通常您可以将 NullField
作为屏幕的第一个视图。
NullField
应该为您接收初始焦点,但请注意,用户仍然可以像使用任何其他视图一样滚动回到它。所以看起来你的重点可能是 "lost",具体取决于你的设计外观。
public class MyScreen extends MainScreen
{
public MyScreen()
{
super(VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL);
add(new NullField()); // Nullfield to be initially focused
// Screen content with focusable button at the bottom
add(new LabelField("Label"));
ButtonField button = new ButtonField("Button");
button.setMargin(1000, 0, 0, 0);
add(button);
}
}