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 4073226
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:59:19+00:00 2026-05-20T16:59:19+00:00

In an Android application I need to add a view to my RelativeLayout that

  • 0

In an Android application I need to add a view to my RelativeLayout that obeys the following rules:

  1. The view should be quadratic, i.e. the height and the width of the view must match.
  2. The view should fill the whole WIDTH.

It should look like this (the square should be centered vertically):

+-------------+
|  activity   |
|             |
|+-----------+|
||           ||
||  square   ||
||           ||
||           ||
|+-----------+|
|             |
|             |
+-------------+

In the end I want to have an ImageView that displays a quadratic image. Currently I did this by setting both width and height of the view to FILL_PARENT, and let the ImageView draw the image correctly (using scaleType=centerInside).

But: Now I want to have an additional view that is aligned with the top line of the square view, and this is where my approach fails.
If I now set the width of the view to FILL_PARENT and the height of it to WRAP_CONTENT, the image will not fit the whole width any longer.

Do you have a solution to this problem? It would be preferrable if this could be done by just writing XML, if possible.

Thanks in advance!

  • 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-20T16:59:20+00:00Added an answer on May 20, 2026 at 4:59 pm

    Look at the top answer on this question.

    Android layout with square buttons

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

Sidebar

Related Questions

I need to add a shake feature that will refresh my Android application. All
I'm developing an Android application that uses native code. I need to add an
I started developing an Android application that record a video and I need to
I need to add my Android application to home screen as shortcut programmatic. Please
i need to add an help window to my android application. But actually i
I'm having trouble in my Android application. I need add LinearLayouts inside another linearlayout.
In one of my Android Application I need to keep the title bar same
I am developing an android application and i need to read words from a
I need to implement Android application which will be expired after few days or
I am developing an android application in which I need to launch an Fragment

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.