user3378649
user3378649

Reputation: 5354

How to create LinearLayout without margins

Beginner here; I am trying to create an application where the design look like

enter image description here

Where I had a header(to wrap the logo), content, and footer.

The problem I faced that when I tried to achieve this sketch is that linear layout can't be fully wraped to the screen. Is there any hack or other way to achieve what I am trying to do.

I am getting something like:

enter image description here

Which makes it ugly to deal with the space, specially if I am trying to do a white background and different color in header.

UPDATE

   <LinearLayout
            android:layout_width="fill_parent"
            android:layout_gravity="top"
            android:layout_height="20dp"
            android:layout_margin="0dp"
            android:orientation="vertical"/>

UPDATE2

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_gravity="top"
            android:layout_margin="0dp"
            android:weight="1"
            android:orientation="vertical"
            android:background="@color/black" />

Upvotes: 0

Views: 286

Answers (1)

Marcin Orlowski
Marcin Orlowski

Reputation: 75636

Are you using any styles? If so, check what's in the style or just set your containers' android:margin and android:padding to 0

EDIT

You need to use match_parent (equals to old, deprecated fill_parent) instead of wrap_content for your middle height otherwise your container won't stretch and you also may want to set android:weight to 1 for it.

Upvotes: 1

Related Questions