JavaFX ScrollPane在Android设备上非常慢

时间:2018-08-29 13:20:09

标签: android javafx gluon-mobile javafxports

我正在jfxmobile-plugin的帮助下在Android上测试JavaFX。尝试在我的android设备上运行它时遇到性能问题。我曾见过类似的问题,但它似乎在2018年仍未解决。有人发布了this question,三年后仍未解决。

这就是我用来构建项目的方式:

  • jfxmobile-plugin:1.3.13(也尝试使用jfxmobile-plugin:2.0.28)
  • dalvik-sdk(尝试版本8.60.7、8.60.8和8.60.9。版本8.60.10和8.60.11使应用程序在启动时崩溃。)

GluonApplication.Java

package com.gluonapplication;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class GluonApplication extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/Dashboard.fxml"));
        Parent root = loader.load();
        Rectangle2D r = javafx.stage.Screen.getPrimary().getVisualBounds();
        Scene s = new Scene(root,r.getWidth(),r.getHeight());
        primaryStage.setScene(s);
        primaryStage.show();
    }
}

Dashboard.fxml

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

<?import javafx.scene.chart.BarChart?>
<?import javafx.scene.chart.CategoryAxis?>
<?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.chart.PieChart?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ProgressIndicator?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" prefWidth="866.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.gluonapplication.DashboardController">
   <children>
      <ScrollPane fitToWidth="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <content>
            <VBox>
               <children>
                  <TitledPane text="Alocação">
                    <content>
                      <AnchorPane>
                           <children>
                              <PieChart fx:id="c_alocacao" layoutX="14.0" layoutY="14.0" prefHeight="400.0" prefWidth="400.0" />
                              <Label layoutX="431.0" layoutY="14.0" text="Total de Ativos:">
                                 <font>
                                    <Font size="18.0" />
                                 </font>
                              </Label>
                              <TableView fx:id="t_ativos" layoutX="447.0" layoutY="71.0" prefHeight="330.0" prefWidth="319.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="415.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="35.0">
                                <columns>
                                  <TableColumn prefWidth="75.0" text="C1" />
                                  <TableColumn prefWidth="75.0" text="C2" />
                                </columns>
                              </TableView>
                           </children>
                        </AnchorPane>
                    </content>
                  </TitledPane>
                  <TitledPane text="Movimentação">
                    <content>
                      <AnchorPane>
                           <children>
                              <ScrollPane fx:id="sp_aportes" layoutX="10.399999618530273" layoutY="10.399999618530273" prefHeight="320" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                 <content>
                                    <BarChart fx:id="c_aportes" minHeight="0.0" prefHeight="300.0" prefWidth="862.0">
                                      <xAxis>
                                        <CategoryAxis minHeight="0.0" side="BOTTOM" />
                                      </xAxis>
                                      <yAxis>
                                        <NumberAxis minHeight="0.0" side="LEFT" />
                                      </yAxis>
                                    </BarChart>
                                 </content>
                              </ScrollPane>
                           </children>
                        </AnchorPane>
                    </content>
                  </TitledPane>
                  <StackPane>
                     <children>
                      <TitledPane text="Proventos">
                          <content>
                            <AnchorPane>
                                 <children>
                                    <ScrollPane fx:id="sp_proventos" layoutX="10.399999618530273" layoutY="10.399999618530273" prefHeight="320" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                       <content>
                                          <BarChart fx:id="c_proventos" prefHeight="300">
                                            <xAxis>
                                              <CategoryAxis side="BOTTOM" />
                                            </xAxis>
                                            <yAxis>
                                              <NumberAxis side="LEFT" />
                                            </yAxis>
                                          </BarChart>
                                       </content>
                                    </ScrollPane>
                                 </children>
                              </AnchorPane>
                          </content>
                        </TitledPane>
                        <ProgressIndicator fx:id="p_proventos" progress="0.0" />
                     </children>
                  </StackPane>
                  <StackPane>
                     <children>                  
                        <TitledPane text="Fatos Relevantes">
                          <content>
                            <AnchorPane>
                                 <children>
                                    <TableView fx:id="t_fatos" layoutX="14.0" layoutY="14.0" prefHeight="650.0" prefWidth="861.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />                              
                                 </children>
                              </AnchorPane>
                          </content>
                        </TitledPane>
                        <ProgressIndicator fx:id="p_fatos" progress="0.0" />
                     </children>
                  </StackPane>
               </children>
            </VBox>
         </content>
      </ScrollPane>
   </children>
</AnchorPane>

build.gradle

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        //classpath 'org.javafxports:jfxmobile-plugin:1.3.13'
        classpath 'org.javafxports:jfxmobile-plugin:2.0.29'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.gluonapplication.GluonApplication'

jfxmobile.android.androidSdk = '/home/helder/Android/Sdk'

dependencies {
    //compileNoRetro 'com.gluonhq:charm:5.0.0'
}

jfxmobile {
    downConfig {
        version = '3.8.0'
        // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
}

当我触摸屏幕时,我会看到很多文本输入到logcat,我认为这可能会使应用程序更加缓慢。因此,我尝试使用proguard(build.gradle上的proguardFile)删除调试调用,但是我在此任务上没有成功,它没有对最终apk进行任何更改。

我尝试在Android 4.4以及Android 6和Android 8上运行该应用程序。所有这些在滚动时都很慢。有人有想法来改善这一点,并使JavaFX在2018年可在Android设备上使用吗?

0 个答案:

没有答案