Две кнопки с одинаковой шириной в макете ограничения - PullRequest
0 голосов
/ 03 июля 2018

Как я могу получить две кнопки рядом в ConstraintLayout с фиксированной и равной длиной?

Примерно так:

enter image description here

1 Ответ

0 голосов
/ 03 июля 2018

Попробуйте этот код ..

<?xml version="1.0" encoding="utf-8"?>
<android.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"
    />

<android.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"
    />
 </android.support.constraint.ConstraintLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...