skip to Main Content

I am following this tutorial and am unable to make Box Three line up to the top of Box Two (which she shows how to do at around 1:45 in the video).

As you can see in the screenshot, I try setting the top margin to 0 but it has no effect on the layout. If I inspect the value again, I see that it has gone back to 16. I am really unsure what I am doing wrong here as I have been following the video quite closely. The tutorial is quite old from 2016 and I am using the newest version of android studio (bumblebee).

Screenshot of me setting the value to 0 but not having any effect on the display:
enter image description here

How can I make the margin 0??

2

Answers


  1. In Box three set height as

        android:layout_height="0dp"
    

    then it will will start from top of box two top( both will be equal )

    Login or Signup to reply.
  2. This is a bug in the latest release: Setting marginTop doesn`t apply when using interface builder, only through XML code. That being said, the issue can be resolved, as you already figured out, by setting the value via ‘Declared attributes’ from the design view or by declaring the value in your code with
    ‘android:layout_marginTop="0dp"’ on your view.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search