Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4123708
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:38:45+00:00 2026-05-20T23:38:45+00:00

I have a RelativeLayout with two children that are also both RelativeLayout s containing

  • 0

I have a RelativeLayout with two children that are also both RelativeLayouts containing a few buttons and things. These children layouts are not centered in my main layout, and the main layout does contain some other things off the the sides of these two. I want the first one to be on top of the second one. That is easy enough, just use android:layout_below="@+id/firstLayout" in the second one. But I also want the second one to be aligned on the center of the first one. By that I mean I want the second layout to find the center of the first one, and align itself so that its center is in the same x position. I see alignLeft, alignRight, alignTop, and alignBaseline, but no center. Is this possible to do without having to hard code a margin to scoot the second layout over some?

Here is a rough example of what I am trying to end up with, the blue bar would be the first layout, and the red box would be the second layout. I know that I could wrap them both in another RelativeLayout that has sizes equal to "wrap_content" and then use centerHorizontal="true" for the second one. But I would really rather leave both as children of my main layout (I would have to make some changes to the way certain parts of my app work if I make them children of a separate layout. Which I am trying to avoid.)

Example of what I want

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:38:46+00:00Added an answer on May 20, 2026 at 11:38 pm

    If you can set width of parent layout to “wrap_content” you could then put both children layouts to center

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a RelativeLayout with a few TextView as children <RelativeLayout android:id=@+id/shift_parent_name android:layout_width=fill_parent android:layout_weight=0.25
I have a problem with a RelativeLayout containing two TextView s and a ImageView
I have a RelativeLayout , and this Layout has two childs, one is a
I have a RelativeLayout with different elements. I was planning to have two ListViews
I have a problem with two Textviews on the same height in a RelativeLayout
I have a simple demo with two buttons. They are laid out with a
I have four buttons arranged in a 2x2 TableLayout. These buttons each have an
I am developing my first Android application. I have created a relativelayout with two
I have a RelativeLayout in which I have two images. The problem is the
i have two buttons next to each other. I want them to be the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.