Чтобы TextView занимал 75 процентов ширины родительского элемента в Android XML, вы можете использовать различные методы. Вот несколько подходов:
Метод 1. Использование LinearLayout с атрибутами WeightSum и Layout_weight:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="4">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Your text here" />
<!-- Other views or TextViews with remaining weight -->
</LinearLayout>
В этом методе атрибут WeightSum задает общий вес LinearLayout, а атрибут Layout_weight указывает вес TextView. В этом случае TextView возьмет 3 части из общего веса 4, что эквивалентно 75 процентам.
Метод 2: использование ConstraintLayout с атрибутом layout_constraintWidth_percent:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/myTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintWidth_percent="0.75"
android:text="Your text here" />
<!-- Other views or TextViews -->
</androidx.constraintlayout.widget.ConstraintLayout>
В этом методе атрибуту Layout_constraintWidth_percent присвоено значение 0,75, что указывает на то, что TextView должен занимать 75 процентов родительской ширины.