Alertdialog.Builder with undue space

Asked

Viewed 65 times

2

I have a space at the bottom of my custom Alertdialog. I don’t know why it’s happening, knowing that I didn’t set any margin or padding at the end of my view. If anyone can help.

Here’s a real print of what’s going on

inserir a descrição da imagem aqui

And here’s my code used...

<?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="wrap_content"
    android:orientation="vertical"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:background="#5454C3">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingTop="15dp"
        android:paddingBottom="5dp"
        android:background="#FF33CC">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="7dp" >

            <br.lgfelicio.elementos.TextViewChanged
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#9B9B9B"
                android:textSize="12sp"
                android:text="DESTINO" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginTop="4dp"
            android:id="@+id/editTextFiltroRegiao">

            <Spinner
                android:id="@+id/spnEstadoFretes"
                android:layout_width="fill_parent"
                android:layout_marginTop="-14dp"
                android:layout_height="wrap_content"/>

        </LinearLayout>

    </LinearLayout>

    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#C0C1C0"
        android:layout_marginTop="-15dp"
        android:layout_marginLeft="7dp"
        android:visibility="visible"/>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingTop="15dp"
        android:paddingBottom="5dp"
        android:background="#00FF00">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="7dp" >

            <br.lgfelicio.elementos.TextViewChanged
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#9B9B9B"
                android:textSize="12sp"
                android:text="COMPLEMENTO" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginTop="4dp"
            android:id="@+id/editTextFiltroComplemento">

            <Spinner
                android:id="@+id/spnComplemento"
                android:layout_width="fill_parent"
                android:layout_marginTop="-14dp"
                android:layout_height="wrap_content"/>

        </LinearLayout>

    </LinearLayout>

    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#C0C1C0"
        android:layout_marginTop="-15dp"
        android:layout_marginLeft="7dp"
        android:visibility="visible"/>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingTop="15dp"
        android:paddingBottom="5dp"
        android:background="#FF0000">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="7dp" >

            <br.lgfelicio.elementos.TextViewChanged
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#9B9B9B"
                android:textSize="12sp"
                android:text="PREÇO" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginTop="4dp"
            android:id="@+id/editTextFiltroPreco">

            <Spinner
                android:id="@+id/spnPreco"
                android:layout_marginTop="-14dp"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>

    </LinearLayout>

    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#C0C1C0"
        android:layout_marginTop="-15dp"
        android:layout_marginLeft="7dp"/>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginTop="5dp"
        android:paddingTop="10dp"
        android:layout_marginLeft="7dp"
        android:background="#000000">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <br.lgfelicio.elementos.TextViewChanged
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/progresTexto"
                android:textColor="#9B9B9B"
                android:textSize="12sp"
                android:text="RAIO" />

        </LinearLayout>

        <SeekBar
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:id="@+id/raioSeekBar"/>

    </LinearLayout>

</LinearLayout>

Solved!

The problem is that I was using negative layout_marginTop, and somehow the layout did not recalculate the height, because the element went up, but pro layout it remains there in the same position.

It was like this...

<View
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="#C0C1C0"
    android:layout_marginTop="-19dp"/>

When I removed the -19, the space on the bottom was gone. And then when I put the View inside a Linearlayout, I was able to put negative margin without having the space problem at the end.

Now it’s like this...

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#C0C1C0"
        android:layout_marginTop="-9dp"/>

</LinearLayout>

Solved. Thanks for the help! Thanks.

  • This is all the code you’ve been using?

  • Yeah, it’s all the code used...

  • try changing this property here: android:paddingBottom="5dp", change to 0dp...

  • The padding you told me to take, is the first group of element that was created, in case it would not interfere with the last element of the alert...

1 answer

1

Remove this line from Linear Layout

android:layout_marginLeft="7dp"

line 157

  • It didn’t work out... In case I remove this line, it will stick on the left side, and I want to remove the space at the end that is staying there without me having put... Because if you do, the buttons are too far away from the last element.

  • I looked at the image and what I thought you wanted to change was the space on the left side in Linearlayout

Browser other questions tagged

You are not signed in. Login or sign up in order to post.