Мой ответ похож на @Basi, но я хочу дать дополнительную информацию с моей точки зрения:
Когда вы работаете с руководящими принципами и устанавливаете ширину вашего вида на wrap_content
, может случиться так, что ваш вид будет перекрыватьсяваше руководство примерно так:
![enter image description here](https://i.stack.imgur.com/OhNx1.png)
Поэтому я рекомендую ограничить обе стороны вашего вида и установить его ширину 0dp
(match_constraints) ипри этом ваш вид будет вписываться в его границы, и ваш ориентир не будет перекрывать ваш взгляд, тогда это будет выглядеть так:
![enter image description here](https://i.stack.imgur.com/lvLcM.png)
Так что есливы хотите использовать рекомендации, как в @Basi, вам лучше использовать 0dp
для вашей ширины:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<TextView
android:id="@+id/textView10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Right"
android:textColor="#F40"
android:textAlignment="textEnd"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline10"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Left"
android:textColor="#F40"
android:textAlignment="textStart"
app:layout_constraintEnd_toStartOf="@+id/guideline10"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Это будет выглядеть так:
![enter image description here](https://i.stack.imgur.com/oQPzq.png)