Невозможно прокрутить JavaFX ComboBox со строками на устройстве Android - PullRequest
1 голос
/ 25 мая 2020

У меня есть поле со списком строк в моем приложении JavaFX.

Когда я открываю поле со списком на рабочем столе, все в порядке, работает нормально.

Когда я портирую на Android, используя javafxports, я не могу прокрутить, когда я пытаюсь, окно закрывается.

Вот видео проблемы: https://www.youtube.com/watch?v=YWGzKrHhZQs

GitLab Repo кода для репликации выпуск: https://github.com/mattlewer/basicComboIssue/tree/master/GluonScroll

Основной класс:

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.Screen;
import javafx.stage.Stage;


public class GluonApplication extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{

        // Loads the FXML and gets the controller
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/assets/basicViewFXML.fxml"));
        Parent root = (Parent)loader.load();
        BasicView basic = loader.getController();

        // Prepare comboBox contents
        String skills[] = {"Overall", "Agility", "Attack", "Construction", "Cooking", 
         "Crafting", "Defence", "Farming", "Fishing", "Fletching", "Herblore",
         "Hitpoints", "Hunter", "Prayer", "Magic", "Mining", "Firemaking",  "Ranged", 
         "Runecraft", "Slayer",  "Smithing",  "Strength",  "Thieving", "Woodcutting" };
        // Add contents to drop down comboBox
        for(String s : skills){
            basic.comboBox.getItems().add(s); 
        }

        // Set Scene
        Scene scene = new Scene(root);
        primaryStage.setScene(scene);

        // Set the size of our app the the size of the users screen and show
        Screen screen = Screen.getPrimary();
        Rectangle2D bounds = screen.getVisualBounds();
        primaryStage.setX(bounds.getMinX());
        primaryStage.setY(bounds.getMinY());
        primaryStage.setWidth(bounds.getWidth());
        primaryStage.setHeight(bounds.getHeight());
        primaryStage.show();
    }

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

Класс контроллера:

package com.gluonapplication;

import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;

public class BasicView{
    @FXML ComboBox comboBox;    
}

F XML:

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

<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="335.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.gluonapplication.BasicView">
   <children>
      <BorderPane prefHeight="600.0" prefWidth="335.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <center>
            <ComboBox fx:id="comboBox" onHidden="#opener" prefHeight="30.0" prefWidth="215.0" BorderPane.alignment="CENTER" />
         </center>
      </BorderPane>
   </children>
</AnchorPane>

файл gradle.build:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.17'  
    }
}

apply plugin: 'org.javafxports.jfxmobile'

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

mainClassName = 'com.gluonapplication.GluonApplication'

dependencies {
    compile 'com.gluonhq:charm:5.0.2'
}

jfxmobile {
    downConfig {
        version = '3.8.6'
        // 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'
        compileSdkVersion = 29
        buildToolsVersion = "29.0.3"

    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

AndroidManifest. xml Файл:

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.gluonapplication" android:versionCode="1" android:versionName="1.0">
        <supports-screens android:xlargeScreens="true"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="21"/>
        <application android:label="GluonApplication" android:name="android.support.multidex.MultiDexApplication" android:icon="@mipmap/ic_launcher">
                <activity android:name="javafxports.android.FXActivity" android:label="GluonApplication" android:configChanges="orientation|screenSize">
                        <meta-data android:name="main.class" android:value="com.gluonapplication.GluonApplication"/>
                        <meta-data android:name="debug.port" android:value="0"/>
                        <intent-filter>
                                <action android:name="android.intent.action.MAIN"/>
                                <category android:name="android.intent.category.LAUNCHER"/>
                        </intent-filter>
                </activity>

                <activity android:name="com.gluonhq.impl.charm.down.plugins.android.PermissionRequestActivity" />
        </application>
</manifest>

РЕДАКТИРОВАТЬ: после перемещения ComboBox в верхний раздел BorderPane , прокрутка теперь работает для верхней левой четверти, но не для всего остального, очень странное поведение https://www.youtube.com/watch?v=D6CKjlNjYh8

...