Я создаю экран профиля пользователя в Android. На этом экране есть обои профиля пользователя и изображение профиля пользователя. Здесь серый фон - обои профиля, а красный фон - изображение профиля. Мне нужно установить красный Б.Г. макет в горизонтальном и вертикальном центре серого макета BG ..Горизонтальный и вертикальный центр для родительского макета
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rlActivityNotificationsAndProfile">
<include layout="@layout/layout_tool_bar"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/profile_wallpaper_container_height"
android:id="@+id/rlProfileWallpaper"
android:layout_below="@+id/toolbar">
<LinearLayout
android:layout_width="match_parent"
android:background="#646464"
android:orientation="vertical"
android:layout_height="@dimen/profile_wallpaper_height">
<LinearLayout
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:background="#A52525">
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:id="@+id/fabEditProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/base_ten_dp"
android:layout_marginEnd="@dimen/base_ten_dp"
android:layout_marginStart="@dimen/base_ten_dp"
android:scaleType="center"
android:src="@drawable/add"
app:elevation="@dimen/priority_1_elevation"
app:fabSize="1"/>
</RelativeLayout>
</LinearLayout>
Использование 'андроида: гравитация =«центр»' для родителей 'LinearLayout' вместо –
Спасибо @RomanKolomenskii –
@RomanKolomenskii если OP подтверждает ваше решение (не так ли?), пожалуйста, ответ от вашего комментария так О.П. может пометить его как завершенное. –