Position of the Autocomplete list

Asked

Viewed 71 times

0

How to position the Autocompletetextview list below it? , I have seen some tutorials and simply the list starts below plus mine is at the top.

inserir a descrição da imagem aqui

 <AutoCompleteTextView
    android:id="@+id/actViewEqp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    android:completionThreshold="2"
    android:dropDownHeight="200dp"
    android:dropDownWidth="match_parent"
    android:ems="10"
    android:hint="ID do equipamento" />
  • 3

    Robson, if the answer below has helped you solve the problem, don’t you think it would be interesting to validate it as you accept it? Or you can also vote positively for her if she has helped you to come up with another solution too. :)

1 answer

2

By default the list of options of the AutoCompleteTextView is positioned below the view if you have enough space. If that doesn’t happen, it will do exactly what is happening to you.

The estate android:dropDownHeight="200dp" defines exactly what the basic height your drop-down list will be. If you set this size of 200dp, it will look for a space equivalent to below to show the contents of the list, otherwise its behavior will not even be as expected, causing it to appear above the view.

It is possible to adjust this size so that it is only 50dp, for example, causing it to show fewer options to the user, but this forces it to fill more text field. It is also possible to password a flexible size if you use the property wrap_content. This will make your drop-down list as small as possible based on your content.

Read more details here in the documentation.

  • I removed these xml settings and the component itself "found" its place, I will update the question.

  • Do you still have any questions? Solved your problem?

Browser other questions tagged

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