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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:22:33+00:00 2026-05-20T10:22:33+00:00

I have a layout with two images: one that should strech to the screen

  • 0

I have a layout with two images:

  • one that should strech to the screen width
  • one above it that should scale to the same proportion the first one was automaticaly scaled (relative to the original image size)

More specific: the two images are slices of the same image, and therefore some details inside them should match.
Can I make this in XML?

If I cannot do it through XML, maybe I could prescale the graphics. In this case, how should I prescale them?

  • 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-20T10:22:33+00:00Added an answer on May 20, 2026 at 10:22 am

    This is a bit of a hack, but it would allow you to do this in xml.

    If you know that, for example, the top image is X% of the size of the bottom one, then you can use LinearLayout’s layout_weight to position and size the top image in terms of percentage of the screen:

    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <ImageView android:id="@+id/left_filler" android:layout_weight="20"
            android:layout_width="wrap_content" android:layout_height="wrap_content"/>
        <ImageView android:id="@+id/top_image" android:layout_weight="50"
            android:layout_width="wrap_content" android:layout_height="wrap_content"/>
        <ImageView android:id="@+id/right_filler" android:layout_weight="30"
            android:layout_width="wrap_content" android:layout_height="wrap_content"/>
    </LinearLayout>
     ... bottom image

    The above would size top_image at 50% of the screen with an offset of 20% from the left. As long as top_image is 50% the size of bottom_image, this will keep similar scale.

    Alternatively, the “right” way to do this is probably to override onDraw() in a custom view and use canvas drawing methods.

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

Sidebar

Related Questions

Right now, I have a layout that looks like one of the two images
I have a layout that contains two ImageViews. I want one of them to
I have a simple page layout with two divs--one on top, and one on
I have a JFrame with null layout and two one character JLabels on the
I have two layouts, one is the main layout inside which I am including
I have created one gridview and use custom adapter for that. I added two
I have created one gridview and use custom adapter for that. I added two
I have a ListView that has one image and two lines of texts for
I have two issues with my CakePHP application (its my first one in CakePHP).
How to automatically switch the background in layout android:background=@drawable/image> I have two pictures I

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.