Search code examples
androidautocompletetextview

Android: Autocomplete Text View


I am developing an android application that uses Google Places autocomplete.

When I select an item from the autocomplete list view the whole string is shown in the autocomplete text view and when it doesn't fit in one row, the text view automatically gets bigger to fit the whole string.

I do not want that to happen, I want the text view to stay the same size, it doesn't matter if the whole string can't be seen. How can I do this??

Another question about autocomplete text view. I need to have a button next to the text view so the user can submit the search. The list view for suggestions is only as wide as the autocomplete text view, it doesn't fill the whole width of the screen, because there is a button on the right side of the text view. Can I make the suggestions list view fill the width of the screen?


Solution

    1. I go with android:singleLine as refer to singleLine.
    2. If you want to make suggestion listview you can use these attribute android:dropDownWidth="xx dp" refer here android:dropDownWidth . You should calculate screen size at runtime to get the right value.

    Other attribute can help you align dropdown listview android:dropDownHorizontalOffset here