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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:22:44+00:00 2026-05-29T07:22:44+00:00

I came across a negative value assigned for an android button proerty as follows.

  • 0

I came across a negative value assigned for an android button proerty as follows.

android:layout_marginTop="-37px"

Does anyone have any idea of what exactly this means…??? 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-29T07:22:45+00:00Added an answer on May 29, 2026 at 7:22 am

    A negative margin can be used to make a View appear smaller to the layout manager when it is been positioned.

    So, for example imagine a View with a height of h and a marginTop of -m. When this view is positioned, the manager will consider the top of the view to be -m rather the 0. In a linear layout situation (assuming vertical layout), this would cause the view to be rendered on top of the previous view.

    You can see this in the example below, as you decrease the top margin of the textView2, it becomes overlaid on textView1.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    
        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="-15dp"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    
    </LinearLayout>
    

    Whether this is specified behaviour or not, I’m not 100% sure. In this post Romain Guy mentions that you can use negative margins, however in this post on Google Groups he mentioned that negative margins behaviour is unspecified.

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

Sidebar

Related Questions

Came across this error today. Wondering if anyone can tell me what it means:
I came across this recently, up until now I have been happily overriding the
I came across this class while reading a C# book and have some questions.
I came across this syntax which i have not seen before struct A {
I came across the WebView class in android.webkit and was impressed by how it
I came across this in a computer architecture textbook: Subtracting a strictly negative integer
Came across a problem which google searches could not help me with. I have
Came across something strange while migrating to my new server. I have a script
Came across something like this today, and was wondering if there was an equivalent
I came across this article written by Andrei Alexandrescu and Petru Marginean many years

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.