Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EditText have always padding from bottom

This is my ListView XML code:

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

    <ListView
        android:id="@+list/list_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/defaultbg"
        android:drawSelectorOnTop="false" />

    <ImageButton
        android:id="@+list/filter_button"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:background="@android:color/transparent"
        android:contentDescription="@string/SmallLogo"
        android:scaleType="fitXY"
        android:src="@drawable/filter" />

    <!-- empty view -->

    <TextView
        android:id="@+list/empty"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/defaultbg"
        android:gravity="center"
        android:text="@string/whos_around_empty_text"
        android:textAppearance="@android:style/TextAppearance.Medium"
        android:textColor="@android:color/white"
        android:textStyle="bold" />

    <EditText
        android:id="@+list/filter"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:hint="@string/search"                
        android:visibility="visible"/>
</RelativeLayout>

The EditText is at the bottom of the view but from some reason it is not tight to the bottom..

When examine it carefully I've seen that the layout is right on bottom - but the inside white background doesn't cover the whole layout (kind of like when the ImageView size is bigger then the layout size and you use scaleType)..

It is really important to me that the EditText will be tight to the bottom... any ideas ??

UPDATE: Adding screen shot:

screenShot

As you can see - the bottom of the editText white background is not aligned down to the bottom of the screen... although the layout itself is aligned

like image 780
Asaf Nevo Avatar asked Jan 29 '13 09:01

Asaf Nevo


1 Answers

In Android, all widgets have some padding and margin from other views for better visibility. Every widget have 4 dp margin and 8 dp padding. If you don't want that you can create a custom view.

For now, Try margin at the bottom with negative pixels.

android:layout_marginBottom="-4dp"

worked fine on my layout

like image 138
Hisham Muneer Avatar answered Sep 17 '22 11:09

Hisham Muneer