Gluon Mobile: Unable to scroll to bottom of scrollPane in Android

168 Views Asked by At

I use a SplashView to show an EULA when the app is started for the first time:

<ScrollPane fx:id="pneContent"  fitToWidth="true" xmlns="http://javafx.com/javafx/8.0.60"
xmlns:fx="http://javafx.com/fxml/1">
<VBox id="boxEula" spacing="8" fillWidth="true">
    <padding>
        <Insets top="0" right="16" bottom="16" left="16"></Insets>
    </padding>
    <TextView fx:id="txtEula" id="txtEula" />
    <HBox spacing="24" alignment="CENTER">
        <Button fx:id="btnDecline" text="%button.decline" styleClass="touch-target" />
        <Button fx:id="btnAccept" text="%button.accept" styleClass="touch-target" />
    </HBox>
</VBox>

TextView extends TextFlow and adds some convenience methods, but no layout logic. It contains several links which will be opened in a browser. When I navigate back from the browser to the splashView I'm not able anymore to scroll to the buttons at the bottom of the scrollPane.

A listener attached to scrollPane.vValueProperty showed that the vMaxValue of '1' is already reached before the bottom of the scrollPane is showing.

I've tried to update the scrollPane content by:

 ServiceHelper.call(LifecycleService.class, s -> s.addListener(LifecycleEvent.RESUME, () -> pneContent.requestLayout()));

without success.

 public EulaPresenter(SplashView splash, Trigger onEulaAccepted) {
    this.splash = splash;
    this.onEulaAccepted = onEulaAccepted;
}

@FXML
protected void initialize() {
    txtEula.addTextWithLinks(Eula.getText(), 3);

    btnDecline.setOnAction(evt -> ServiceHelper.call(LifecycleService.class, LifecycleService::shutdown));
    btnAccept.setOnAction(evt ->
        {
            dispose();
            onEulaAccepted.start();
        });

    splash.setCenter(pneContent);
    initFab();

    clickedOnScrollFilter = new MouseClickedOnScrollFilter(pneContent);
    clickedOnScrollFilter.activate();

    Listeners.executeOnceWhen(pneContent.layoutBoundsProperty(), () -> !pneContent.isFocused(), e -> Platform.runLater(() ->
        {
            pneContent.setVvalue(0);
            pneContent.setOpacity(1);
        }));
}

private void initFab() {
    fab = new FloatingActionButton();
    fab.setFloatingActionButtonHandler(FloatingActionButton.TOP_RIGHT);

    fab.textProperty().bind(new When(pneContent.vvalueProperty().isEqualTo(pneContent.vmaxProperty())).then(MaterialDesignIcon.ARROW_UPWARD.text)
                                                                                                      .otherwise(MaterialDesignIcon.ARROW_DOWNWARD.text));
    fab.setOnAction(e ->
        {
            if (fab.getText() == MaterialDesignIcon.ARROW_DOWNWARD.text) {
                pneContent.setVvalue(pneContent.getVmax());
            } else {
                pneContent.setVvalue(pneContent.getVmin());
            }
        });

    splash.getLayers().add(fab.getLayer());
}

private void dispose() {
    splash.getLayers().remove(fab.getLayer());
    fab.textProperty().unbind();
    fab = null;

    clickedOnScrollFilter.deactivate();
    clickedOnScrollFilter = null;
}

}

0

There are 0 best solutions below