1
我尝试了snapToGrid,我认为这可能只是简单的解决方案,希望用于带有侧滑条目的列表。 但是,如果我禁用了张力拉伸启用,那么当行对齐网格时没有动画。 有一种方法可以禁用X轴上的拉伸滚动,同时使snapToGrid仍然动画?没有使用snapToGrid滚动和tensileDragEnabled设置为false的动画
下面的代码:
public class FormScrollingXY extends Form {
public FormScrollingXY() {
setTitle("FormScrollingXY");
setScrollable(false);
setScrollableY(true);
setLayout(new BoxLayout(BoxLayout.Y_AXIS));
for (int rowIndex = 0; rowIndex < 50; rowIndex++) {
Container containerRow = new Container(new BoxLayout(BoxLayout.X_AXIS));
containerRow.setSnapToGrid(true);
containerRow.setScrollableX(true);
containerRow.setTensileDragEnabled(false); // bad behaviour
for (int columnIndex = 0; columnIndex < 3; columnIndex++) {
Container containerColumn = new Container(new FlowLayout()) {
@Override
protected Dimension calcPreferredSize() {
Dimension dimension = new Dimension(super.calcPreferredSize());
dimension.setWidth(containerRow.getWidth());
return dimension;
}
};
containerColumn.add(new Label((rowIndex + 1) + "/" + (columnIndex + 1)));
containerRow.add(containerColumn);
}
add(containerRow);
}
}
}
重载isSrollableY()不会改变任何东西 - 无论如何它都会返回false。 事情是 - 显然snapToGrid只有在tensileDraghEnabled为true时才起作用。但我不想在X轴上进行拉伸滚动。我想要的是与动画对齐的网格行为。 –
好的,我想我在代码中看到了问题。对齐网格使用拉伸代码来执行实际动画,所以我为此添加了特殊情况。应该成为今天更新的一部分。 –