Question: ![enter image description here](https://i.stack.imgur.com/fGElK.png)

As xml:

```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="20dp">

    <Button
        android:id="@+id/locationButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:minWidth="46dip"
        android:onClick="getLocation"
        android:text="@string/icon_map_marker" />

    <AutoCompleteTextView
        android:id="@+id/autocomplete_city"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:hint="@string/city_hint"
        android:inputType="text"
        android:layout_alignBottom="@+id/locationButton"
        android:layout_alignTop="@id/locationButton"
        android:layout_toLeftOf="@id/locationButton"
        android:dropDownWidth="match_parent"
        />

    <requestFocus />

</RelativeLayout>

```

As you can see the 

```
android:dropDownWidth="match_parent"

```

ignores the padding of the relative layout. Any ideas how to fix this?

Answer: 
Solved it. I had to define another relative layout wrapping only the autocomplete textview and the button. This layout is the anchor of the popup, taking the width of the relative layout as its own width.The key:

```
android:dropDownWidth="wrap_content"
android:dropDownAnchor="@+id/anchor"

```

Short version:

```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="20dp" >

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/anchor" >

        <Button
            android:id="@+id/locationButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true" />

        <AutoCompleteTextView
            android:id="@+id/autocomplete_city"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/locationButton"
            android:layout_alignTop="@id/locationButton"
            android:layout_centerHorizontal="true"
            android:layout_toLeftOf="@id/locationButton"
            android:dropDownWidth="wrap_content"
            android:hint="@string/city_hint"
            android:dropDownAnchor="@+id/anchor" />

        <requestFocus />

    </RelativeLayout>

</RelativeLayout>

```
```
//try this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp">

    <AutoCompleteTextView
        android:id="@+id/autocomplete_city"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:hint="city_hint"
        android:inputType="text"
        android:dropDownWidth="match_parent"/>
    <Button
        android:id="@+id/locationButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minWidth="46dip"
        android:onClick="getLocation"
        android:text="icon_map_marker" />
</LinearLayout>

```