6

I have a dialog window that covers 1/3 of the entire screen height and is displayed on top of my activity. The dialog holds two AutoCompleteTextView fields.

The problem I'm facing is that when the user starts typing something into the AutoCompleteTextView, the list with all suggestions only shows up to the bottom end of the dialog, but doesn't go beyond that even the list is longer. It looks like it's cut off. (screenshot left)

Only after I long-press an item from the suggestion list, the list will be shown in full length. (screenshot right)

Screenhot is at: http://img704.imageshack.us/i/dialogdropdown.png/ screenshot http://img704.imageshack.us/img704/1893/dialogdropdown.png

How to fix this behaviour so that the list shows in full length right from the beginning, when the user starts typing something?

Code-wise there's nothing special, all I do is:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getContext(), R.layout.nav_route_autocomplete_row, locStrings);        
AutoCompleteTextView txtStartPos = (AutoCompleteTextView) findViewById(R.id.txtStartPos);
txtStartPos.setAdapter(adapter);
...

One workaround idea is to somehow dispatch a motion event to simulate a touch (but then not selecting though) one of the list items. Any concrete idea in code for a solution, anybody?

Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192

6 Answers6

1

Not long ago i faced this problem. I had small dialog with AutoCompleteTextView, which had more than 10 items in Drop Down list. This list was cutted. My solution was:
Place some empty View in my Dialog layout file with parameters

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
<!--
Some Views placed here
-->
       <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="invisible" />

</LinearLayout>

It made my little dialog like a full screen dialog, but actualy that "tail" wasn't showed, and my DropDown wasn't cutted at all, cause it had enough place to show list items from DropDown.

Procurares
  • 2,169
  • 4
  • 22
  • 34
1

Right now I'm assuming it's a bug, which I already filed here: http://code.google.com/p/android/issues/detail?id=9917

But if anybody knows a solution to this, I'd greatly appreciate it and would be glad to trade it for some bounty points.

Edit:

One workaround that came to my mind is now to extend the dialog to the very bottom of the screen but leave the background transparent, so it looks the same as now, but actually has a height that wouldn't cut off the list. I will give that a try...

Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
1
if (yourlist.size() > 5) {
    yourtextview.setDropDownHeight(562);
} else {
    yourtextview.setDropDownHeight(anytextview.getHeight() * yourlist.size());
}

//Workaround ->  Write this condition under on click and on focus change of your autocomplete text view 
Piotr Labunski
  • 1,638
  • 4
  • 19
  • 26
kartik_g
  • 21
  • 2
0

As seen here: Scrolling drop-down-menu over the keyboard in autocompletetextview

You can use the property android:dropDownHeight of the AutoCompleteTextView to force it to be of a certain height. This is not really solving the problem, but is the best I could find.

Note: This problem only happens when using AutoCompleteTextView inside a Dialog. When it is used on the layout of an activity or a fragment it just works fine.

This issue is present all the way from Gingerbread to Jelly Bean.

Community
  • 1
  • 1
shalafi
  • 3,926
  • 2
  • 23
  • 27
0

Just a shot in the dark, but have you tried setting android:clipChildren to false on the view for the dialog atop your Activity?

iandisme
  • 6,346
  • 6
  • 44
  • 63
  • I tried so set that attribute for the very outer LinearLayout of my dialog layout, and also for all others of which the AutoCompleteTextView is a (sub)child of. But it doesn't help. Since it's a dialog, it should be more of like window.setClipChildren(false), but unfortunately such a method doesn't exist for window. Or some flags like window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); but that all doesn't help. – Mathias Conradt Aug 04 '10 at 03:20
0

I have successfully achieved this, but it isn't pretty.

I ended up overriding my SimpleCursorAdapter.newView() method, walking up the ViewParent hierarchy until I reached the root View, and then modifying its WindowManager.LayoutParams by ORing in the FLAG_LAYOUT_NO_LIMITS flag.

This needs to be redone every time the drop down is displayed.

Aaron Klotz
  • 11,287
  • 1
  • 28
  • 22