Я хочу, чтобы центрировать все содержимое макета до центра, но это проблема, которую я имею:центр ImageView и TextView бок о бок
Как вы можете видеть, я хочу, чтобы отцентрировать изображение и текст в их родитель, но хотите иметь изображение слева от текста.
Вот код макета:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/app_light_green" >
<ImageView
android:id="@+id/toastImage"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:paddingTop="1dp"
android:src="@drawable/exclamation" />
<TextView
android:id="@+id/toastText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:paddingBottom="3dp"
android:paddingLeft="5dp"
android:paddingRight="3dp"
android:paddingTop="2dp"
android:textColor="@color/app_darker_green"
android:textSize="@dimen/sixteen_sp" />
</RelativeLayout>
Посмотрите https://stackoverflow.com/a/39958875/3278589 – Subho