javaandroidlayoutautocompletetextview

Aligning TextView and AutoCompleteTextView side by side in Android


I'm trying to align the following AutoCompleteTextView (Type group location..) and the TextView (Radius) to the left, regarding the top ImageView.

enter image description here

As you can see, it doesn't work. Here's my xml layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="0dp">


<ImageView
        android:id="@+id/icon"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_alignParentLeft="true"/>

    <AutoCompleteTextView
        android:id="@+id/autocomplete_textview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/icon"
        android:layout_below="@+id/icon"
        android:paddingBottom="0dp"
        android:inputType="textAutoComplete"
        android:textSize="16sp" />
    
    <TextView
        android:id="@+id/radiusText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/autocomplete_textview"
        android:layout_alignLeft="@+id/icon"
        android:textSize="16sp"
        android:paddingTop="5dp"/>
    
</RelativeLayout>

What I already tried and failed:

Aligning the TextView with the regard to the AutoCompleteTextView, and also aligning both views with regard to parent view.

I suspect the AutoCompleteTextView has some transparent trailing, or I'm missing something.


Solution

  • Found my solution at least.

    For some reason AutoCompleteTextView has default padding, once I set the paddingLeft to 0, it fixed the problem. :)