gpt4 book ai didi

android - 约束布局中两个等宽的按钮

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:36:40 25 4
gpt4 key购买 nike

如何在 ConstraintLayout 中并排放置两个固定且等长的按钮?

像这样:

enter image description here

最佳答案

试试这段代码..

<?xml version="1.0" encoding="utf-8"?>
<androidx.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:text="Button 1"
app:layout_constraintLeft_toLeftOf="parent"
android:textAllCaps="false"
app:layout_constraintRight_toLeftOf="@+id/guideline"
/>

<androidx.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />

<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:text="Button 2"
android:textAllCaps="false"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@+id/guideline"
/>
</androidx.support.constraint.ConstraintLayout>

关于android - 约束布局中两个等宽的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51155009/

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