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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:08:10+00:00 2026-06-14T10:08:10+00:00

I want that when I set margin bottom, which makes part of the view

  • 0

I want that when I set margin bottom, which makes part of the view go out of the screen / not visible, the whole layout shifts to the top, looking “the same” – means, not re-arranging the views inside.

But when I set the margin, in this simplified example case, to container shrinks or the layout inside moves to the bottom. Here are pictures to illustrate:

Before setting margin:

enter image description here

After setting 200dip margin bottom:

enter image description here

This is the XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="400dip"
        android:background="#ff0000"
        android:gravity="center"
        android:layout_marginBottom="200dip"
        >

        <View 
            android:layout_width="fill_parent"
            android:layout_height="200dip"
            android:background="#00ff00"
            />

    </LinearLayout>

    <Button
        android:id="test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:text="@string/hello_world"
        tools:context=".MainActivity" />


</RelativeLayout>

What can I do to avoid this?

  • 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-06-14T10:08:11+00:00Added an answer on June 14, 2026 at 10:08 am

    To achieve that, try setting a negative top-margin top the view you want to move up.

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="400dip"
            android:background="#ff0000"
            android:gravity="center"
            android:layout_marginTop="-200dip"
            >
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that has a tooltip attribute. I want to set that
I have UserControls containing other controls. I want that if I set a Foreground
I have a Stackpanel and want that the items automatically set their sizes regarding
I have a set of buttons. I want that when I do mouse up
How can I set Tomcat to automatically redirect to www? I want that if
I am trying to set focus on a hidden text box. I want that
I want to create a custom set that will automatically convert objects into a
I want to create a method ( set ) that injects arguments into another
I have a div set transparent with rgba and want on that div an
I just want to set a crontab using that I want to make a

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.