gpt4 book ai didi

layout - 如何在基线处对齐标签和按钮?

转载 作者:行者123 更新时间:2023-12-02 17:28:05 25 4
gpt4 key购买 nike

我想在水平布局中放置一个标签和一个按钮(以及一个文本字段)。这有效,但基线未对齐。如何解决?

Baselines are unaligned

预期的结果是红线(每个控件的基线)在同一高度。

这是 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>

最佳答案

将对齐属性添加到 HBox,值为 "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>

enter image description here

关于layout - 如何在基线处对齐标签和按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36890186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com