хочу спросить, как сделать текст на кнопке, чтобы автоматически настроить его размер, чтобы соответствовать кнопке. Я попытался установить
android:autoSizeTextType="uniform"
, но это не работает, и текст все равно в итоге становится 2-й строкой, и когда я положил
android:maxLines="1"
какая-то его часть пропала, есть ли способ автоматического изменения размера текста, чтобы он соответствовал кнопке, чтобы она имела максимальную длину в 1 строку и отображал весь текст программно или xml?
Я новичок ie, поэтому любые советы будут действительно оценены. Заранее спасибо
Редактировать:
Вот мой xml, текст кнопки, который я хочу разместить, btnReq и btnA cc
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".PlayFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
app:layout_constraintBottom_toTopOf="@+id/tableLayout"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.074"
tools:layout_editor_absoluteX="0dp">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingRight="10dp">
<EditText
android:id="@+id/et_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ems="10"
android:hint="email"
android:inputType="textPersonName"
android:autoSizeTextType="uniform"/>
<Button
android:id="@+id/btnReq"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="REQUEST"
android:autoSizeTextType="uniform"
android:maxLines="1"/>
<Button
android:id="@+id/btnAcc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ACCEPT"
android:autoSizeTextType="uniform"
android:maxLines="1"/>
</LinearLayout>
</LinearLayout>
<TableLayout
android:id="@+id/tableLayout"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true"
android:padding="10dp"
app:layout_constrainedHeight="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="percent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_default="percent">
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
<Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
<Button
android:id="@+id/btn6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<Button
android:id="@+id/btn7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
<Button
android:id="@+id/btn8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
<Button
android:id="@+id/btn9"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
</TableRow>
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>