A
A
ArtemEfremov2020-08-29 18:06:13
Android
ArtemEfremov, 2020-08-29 18:06:13

Problem with RelativeLayout, how to solve?

The problem is that the elements in the Relative Layout do not want to be centered horizontally, even if the property layout center horizontal = true, the Relative Layout is nested in the Scroll View.

Help, I will be very grateful

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_height="match_parent"
  android:layout_width="match_parent">

  <RelativeLayout
    android:layout_height="wrap_content"
    android:layout_width="wrap_content">

    <ProgressBar
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:layout_centerHorizontal="true"/>

  </RelativeLayout>

</ScrollView>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2020-08-30
@ArtemEfremov

This is because you made the RelativeLayout the size of the child(wrap_content). Naturally, in this case, the child is always "in the center" of this layout. Set the width of the match_parent RelativeLayout.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question