vendredi 8 mai 2015

JavaFX ScrollPane on Android - Too

I have just coded a simple example of using a scrolling pane in JavaFX. Just one ScrollPane placed in the Scene, and the ScrollPane holds a Label component with a large text. Using gradle I have uploaded the app on a Nexus 4 android device. As you can see from the video I have uploaded, the scrolling is way too slow. I am sure others have experienced this. Any suggestion of how this can be changed to the native speed scroll is really much appreciated.

Source code of the app can be downloaded from here.

AndroidFX.java

public class AndroidFX extends Application{

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Parent mySearchListFXML = getFXMLPane("/fxml/ScrollPaneWithLabel.fxml");
        primaryStage.setScene(new Scene(mySearchListFXML));
        primaryStage.setWidth(Screen.getPrimary().getVisualBounds().getWidth()); primaryStage.setHeight(Screen.getPrimary().getVisualBounds().getHeight());     
        primaryStage.show();
    }

    public static Parent getFXMLPane(String url) throws IOException {
        URL location = AndroidFX.class.getResource(url);
        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(location);
        Parent pane = fxmlLoader.load();
        return pane;
    }
}

ScrollPaneWithLabel.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>

<ScrollPane fx:id="scrollPane" fitToWidth="true" hbarPolicy="NEVER" pannable="true" style="-fx-background: white;" xmlns="http://ift.tt/1cgvoBd" xmlns:fx="http://ift.tt/1cgvoBb">
   <content>
      <Label text="<VERY LARGE TEXT HERE>" wrapText="true" />
   </content>
</ScrollPane>

Aucun commentaire:

Enregistrer un commentaire