Я попытался добавить текст и значок на кнопки, используя «android: text» и «android: drawableTop», но полученный результат не совсем корректен.Текст и значок не центрированы, и если я попробую приложение в альбомной ориентации или изменим размер экрана, текст исчезнет, и значок немного выйдет из кнопки.
Это макет без обоих "android:text "and" android: drawableTop ":
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">
<Button
android:id="@+id/redButton"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="4dp"
android:background="#FF0000"
app:layout_constraintBottom_toTopOf="@+id/blueButton"
app:layout_constraintEnd_toStartOf="@+id/yellowButton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/greenButton"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="4dp"
android:background="#00FF00"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/blueButton"
app:layout_constraintTop_toBottomOf="@+id/yellowButton" />
<Button
android:id="@+id/blueButton"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="4dp"
android:background="#0000FF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/greenButton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/redButton" />
<Button
android:id="@+id/yellowButton"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="4dp"
android:background="#FFFF00"
app:layout_constraintBottom_toTopOf="@+id/greenButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/redButton"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Интересно, есть ли способ сделать текст и значки отзывчивыми, потому что я также пытался использовать значки SVG, но они не показывались.
Результат, который я получаю:
Портрет & Пейзаж
Любая помощь будет оценена, спасибо.