我想在水平布局中放置一个标签和一个按钮(和一个文本字段)。这有效,但基线未对齐。如何解决?
预期的结果是红线(每个控件的基线)处于相同的高度。
这是 FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.HBox?>
<HBox prefHeight="100.0" prefWidth="400.0" spacing="10.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label text="Label" />
<Button mnemonicParsing="false" text="Button" />
<TextField text="Lorem Ipsum" />
</children>
</HBox>
Run Code Online (Sandbox Code Playgroud)
向HBox
with 值添加对齐属性"BASELINE_LEFT"
:
<HBox alignment="BASELINE_LEFT" prefHeight="100.0" prefWidth="400.0" spacing="10.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label text="Label" />
<Button mnemonicParsing="false" text="Button" />
<TextField text="Lorem Ipsum" />
</children>
</HBox>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1580 次 |
最近记录: |