pedro.olimpio
pedro.olimpio

Reputation: 1498

How to align RelativeLayout with margins 0

I've this question:

How to align the RelativeLayoutto align left right and top in the following case?

enter image description here

I want remove this white space and align the blue and yellow RelativeLayout in the screen.

here is my layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#EAEAEA" >

    <RelativeLayout
        android:id="@+id/layout_cenas_bottom"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"

        android:background="#FFFF00" >

        <Button
                android:id="@+id/btnAdicionarCenas"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/title_adicionar_cena"
                android:layout_weight="1"
                android:background="@drawable/mybutton"
                android:textColor="@drawable/mybuttoncolors"
                android:textSize="15sp"
                android:layout_marginBottom="10dp">
            </Button> 

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/layout_cenas_conteudo"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:layout_above="@id/layout_cenas_bottom"
        android:layout_alignParentTop="true"
        android:background="#00FFFF">

    <ListView
        android:id="@+id/lvCenas"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </ListView>

    </RelativeLayout>


</RelativeLayout>

Upvotes: 1

Views: 331

Answers (2)

eldivino87
eldivino87

Reputation: 1435

Look in the dimens.xml if you have something like this:

<dimen name="activity_horizontal_margin">8dp</dimen>
<dimen name="activity_vertical_margin">4dp</dimen>

Check if your layout (or the parent layout) use them, for example:

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"

if yes then remove them or change the values in the dimens.xml to 0dp.

Upvotes: 0

deadfish
deadfish

Reputation: 12304

Looks like Your layout is a part of activity layout. So, please check if your main activity has main layout with android:paddingXXX params and remove it.

Upvotes: 1

Related Questions