Проверьте горизонтальный код LinearLayout ниже, чтобы увидеть, как работает тег layout_weight
.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#EBEEE8E8"
android:orientation="horizontal">
<TextView
android:id="@+id/txtpessoa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pessoa: "
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txtPessoaNome"
android:layout_width="0dp"
android:layout_weight="1"
android:text="This is the name that you want!"
android:layout_height="wrap_content"
android:textStyle="bold" />
</LinearLayout>
Этот код является наиболее правильным для достижения того, что вы хотите. С атрибутом layout_weight="1"
, с layout_width
или layout_height
, установленным на 0dp
, вы сможете сделать так, чтобы этот потомок повторного просмотра занимал все оставшееся пространство в макете.