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
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.
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.
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...
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
Just a shot in the dark, but have you tried setting android:clipChildren
to false
on the view for the dialog atop your Activity?
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.