I've written a small javafx app that animates a square moving from the top-left corner to bottom-right. It then reverses the animation and runs it continuously. On my pixel 4 (xxhdpi) the square leaves behind a trail of edges on the return trip. This does not happen on on my Nexus 7 2013 (xhdpi) or on my desktop.
Tried both the gluon plugin and also the gluon-vm plugin.
Seems related to screen pixel density . . . how do you prevent the ghosting artifacts on dense screens? Image and code below.
Pixel 4 screenshot:

Nexus 2013 Screenshot:

And the app:
public class StockJavaFx extends Application {
@Override
public void start(Stage primaryStage) {
Dimension2D dimension = Services.get(DisplayService.class)
.map(DisplayService::getDefaultDimensions)
.orElseThrow(() -> new NullPointerException("DisplayService"));
Rectangle rectangle = new Rectangle(75, 75);
Pane container = new Pane();
container.getChildren().add(new Rectangle(dimension.getWidth(), dimension.getHeight(), Color.DARKSLATEGRAY));
container.getChildren().add(rectangle);
Scene scene = new Scene(container);
primaryStage.setScene(scene);
TranslateTransition tt = new TranslateTransition(Duration.millis(750), rectangle);
tt.setFromX(0);
tt.setToX(dimension.getWidth() - 75);
tt.setFromY(0);
tt.setToY(dimension.getHeight() - 75);
tt.setCycleCount(Animation.INDEFINITE);
tt.setAutoReverse(true);
FillTransition ft = new FillTransition(Duration.millis(750), rectangle);
ft.setFromValue(Color.ORANGERED);
ft.setToValue(Color.CADETBLUE);
ft.setCycleCount(Animation.INDEFINITE);
ft.setAutoReverse(true);
tt.play();
ft.play();
primaryStage.show();
}
}
The old Gluon
jfxmobileplugin is more or less EOL, and it's being replaced by the new Gluon Client plugin. More details can be found here and here. Detailed documentation can be found here.This is how you can try creating an Android app that will solve the "ghosting" issue, with some extra "small" benefits, like using Java and JavaFX 11+, GraalVM, and getting a much more performant app. Note that the client plugin for Android is still under heavy development and it's not ready for production yet.
Before you get started, please check that you follow the prerequisites here:
Set
GRAALVM_HOMEenvironment variable to the GraalVM installation directory, like:export JAVA_HOME=$GRAALVM_HOMEYou can modify one of the existing samples, like HelloGluon.
You can modify the pom to use the latest versions like:
Now you can modify the main view to add your transition:
You can now run with your regular JDK on your machine:
and verify that works fine.
If that is the case, you can now create a native image with GraalVM, also on your machine:
This is a lengthy process, that requires usually 16 GB RAM, and a few minutes.
Once finished successfully, you can run it:
It should work as expected:
Finally, you can try to build an Android native image:
When finished, create the apk:
It will create an apk under
target/client/aarch64-android/gvm/apk/bin/hellogluon.apk.Plug a device, to install and run:
Note: by default, icon assets and AndroidManifest are generated at
target/client/aarch64-android/gensrc/android. If you want to modify either of them, you have to copy the content of this folder tosrc/android.