我需要顯示的圖像的寬度/高度在imegView並將其與原單圖像尺寸,該尺寸在imageView.getImage()。的getWidth()/的getHeight(),並且如果用戶調整其大小形成應用GUI聽變化。如何獲得在javafx imageView中顯示圖像的寬度/高度?
我從imageView.fitWidthProperty()
這個大小和高度相似,但我得到在它的ImageView的不是圖像尺寸:
我得到藍色的大小是ImageView的,但我需要顯示的圖像的大小(綠色) 。我怎樣才能得到它作爲屬性來監聽用戶調整窗口應用程序的大小(綠色也改變大小,但它似乎有最大和最小大小,所以它停止與最大或最小的imageView調整大小)。
我使用這個屬性來計算原單圖像的大小%以下藍色矩形右下角。
可能嗎?
E:下面是此標籤的FXML:
<BorderPane fx:id="root" fx:controller="..."
xmlns:fx="..." xmlns="..." stylesheets="@...css">
<center>
<StackPane>
<ImageView fx:id="..."/>
<fx:include source="...fxml" fx:id="..."/>
</StackPane>
</center>
<bottom>
<VBox fx:id="..." minHeight="110" styleClass="small-padding" spacing="5">
<HBox alignment="CENTER_RIGHT" spacing="5">
<fx:include source="...fxml" resources="..."
fx:id="..."/>
</HBox>
<TextArea fx:id="..." promptText="%..." styleClass="-fx-description-text-area"/>
</VBox>
</bottom>
imageView.getFitWidth()不起作用。但我發現我需要imageView.boundsInParentProperty()所以問題解決了。 – xav9211