Skip to content

多个大小不一元素(两边元素小,中间元素大)居中对齐的问题 #28

@dshcao

Description

@dshcao

ConstraintLayout(
children: [
Guideline(
id: guideline,
horizontal: true,
guidelinePercent: 0.5),
Text(
'aaa',
style: TextStyle(
color: llmType > 0
? AppColors.textLGray
: AppColors.textWhite,
fontSize: 16),
textDirection: TextDirection.ltr,
).applyConstraint(
left: parent.left, centerVerticalTo: sId(1)),
Switch(
value: llmType > 0,
onChanged: (value) {
setState(() {
value ? llmType = 1 : llmType = 0;
});
})
.applyConstraint(
left: sId(-1).right, bottom: parent.bottom),
Text(
'bbb',
style: TextStyle(
color: llmType > 0
? AppColors.textWhite
: AppColors.textLGray,
fontSize: 16),
textDirection: TextDirection.ltr,
).applyConstraint(
left: sId(-1).right, centerVerticalTo: sId(-1)),
],
) 这个好像不起作用,第一个(aaa)元素和第三个(bbb)元素高度较小,但是三个元素要求水平居中对齐,所以aaa和bbb都要要相对较大的中间元素Switch看齐(对齐)。现在这样写好像不起作用,aaa没法后一个元素Switch对齐

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions