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?
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...
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.
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.
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.
Related
I have an ExpandableListView which contains a RecyclerView of a custom layout. This layout contains some views including my EditText.
My behavior is : When I click in my number EditText, the keyboard appears for about 0.5s, the whole layout is cleared with default values, then the keyboard disappears, a text EditText appears, and finally I loose focus. When I click on it one more time, the keyboard stays, but in text type. Strange thing : the problem seems to be only on devices where the whole layout overflows the screen because on 10" tablet, everything is ok (layout not cleared, and keyboard not disappearing).
According to me, when I get the focus in the EditText, the layout is re-creates , making it to be cleared.
I tried a long time to figure out what was going on, but I didn't find anything. Here is the things I tried, but didn't change anything :
android:descendantFocusability="beforeDescendants" // on all parent of the EditText
focusable="true" // On the EditText
android:windowSoftInputMode="adjustPan" // In the activity in the manifest
making all the ViewHolder attributes final
As the code is very huge for all that amount of things, I don't know what I should post to help. So don't hesitate to ask anything if it can help
Thanks!
EDIT : A Gif showing the issue https://imgur.com/a/BPue4
Try adding this line to your activity on manifest.xml:
android:configChanges="keyboardHidden|screenSize"
Opening keyboard or screen size changes may trigger to re-create your content.
I'm developing an application and I am facing a problem using ExpandableListView. What I'm trying to do is, in GroupHeader, not only show the group name, but also an spinner with options. That's because I want to show the football second division games in the list but, also, give the option to choose the round, in case the user wants to check older/future games. SO far I have that
As you can see both, title and spinner, shows. Also you can see the arrow on the right which is supposed to expand the list. Problem is that, if I click, only spinner opens, group expand button doesn't. So, here is my question, how can I make both of them work depending on where you click (one or another)??? Is that possible?
Also I must say that if I only place the TextView with the group name works perfect. If I only place the spinner, the problem persists. So I'm guessing that's a focus problem.
Btw: grey areas are the layout backgrounds, so no, they are not hiding behind the button.
I found the solution, I just neede to add this line android:descendantFocusability="blocksDescendants" to the Main Layout of the xml where I define the GroupHeader elements.
I have an AutoCompleteTextView item in my app layout. I'd like to reserve just a tiny space for it in the layout, so the user can touch it and begin to write. Instead, I'd like that the list with suggested words that pops up is wider, for example like the entire screen. Actually, the pop-up words list is as wide as the textView.
I've found a simple solution. Attribute android:dropDownWidth. For example, I can set android:dropDownWidth="match_parent". Excuse me for posting a question and then founding the answer immediately after.
did one of you ever run into that problem ?
With some high resolutions screen it displays correctly :
but the low resolutions it's not displaying correctly are not so low, for example, in galaxy spica (320x480px). I would like the keyboard to be brought behind the suggestions list when this one gets the focus from the user who's trying to scroll on it with one long click..
I' ve tried : android:windowSoftInputMode="stateHidden|adjustPan" in the activity manifest.xml and all other combinations. still, it's not working...
I tried to change the text size, the items size, the padding, the max height of the whole autocompletetextview, the max height of dropdownlist, tried a MultiAutoCompleteTextView, even tried to nest it in a scrollview, nothing.
it occurs because of the keyboard which "pushes" the list items above the textview so without the keyboard everything would be nice..
any help would be much appreciated...
Just add android:dropDownHeight="100dp" to the AutoCompleteTextView tag in your layout file,
#Override
public void onFilterComplete(int count) {
setDropDownHeight((count > DROPDOWN_LIST_COUNT ? DROPDOWN_LIST_COUNT : count) * getHeight()
+ DROPDOWN_LIST_BORDER);
super.onFilterComplete(count);
}
I've encountered the same problem and tried the code above. It makes sure dropdownlist shows DROPDOWN_LIST_COUNT items.
You can try this method:
autoCompleteTextView.setDropDownVerticalOffset();
There was more screen space above the AutocompleteTextView than below, so the list opened upwards. You may adjust your layout to make sure there's more screen space(exclude the pop up keyboard)below the AutocompleteTextView. This issue seems has been fixed from ICS.
I have 3 autocompletetextview's in which i set its adapter to be an ArrayAdapter<String> with a very simple textview layout.
The autocompletextview hint results are showing, but are under the onscreen keyboard(i can see part of it). how can i make the results show above the autocompletetextview rather than below?
airline = (AutoCompleteTextView)findViewById(R.id.airline);
airline.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, AIRLINES_AUTOCOMPLETE_ARRAY));
departLocation = (AutoCompleteTextView)findViewById(R.id.departLocation);
departLocation.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, LOCATIONS_AUTOCOMPLETE_ARRAY));
arriveLocation = (AutoCompleteTextView)findViewById(R.id.arriveLocation);
arriveLocation.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, LOCATIONS_AUTOCOMPLETE_ARRAY));
Simply limit the drop-down height.
android:dropDownHeight="200dp"
Then results don't hide by the soft keyboard.
Or else do this
The theory says that android:windowSoftInputMode="adjustPan|adjustResize" should do this but for some reason, it doesn't, so you have to do the same programmatically:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Use a ScrollView for the layout where your Autocomplete resides and Voila!
Does your Activity adjustResize?
android:windowSoftInputMode="adjustPan|adjustResize"
reference: Move layouts up when soft keyboard is shown?
you should look here : Creating an input method
Composing text before committing
If your IME does text prediction or requires multiple steps to compose a glyph or word, you can show the progress in the text field until the user commits the word, and then you can replace the partial composition with the completed text. You may give special treatment to the text by adding a "span" to it when you pass it to InputConnection#setComposingText().
this way, suggestions will apears on soft keyboard prediction like auto-correction. An other way of doing it will be a fullScreen IME... with ExctractEditText : See this link...
This is what i usualy have seen in other apps... i don't think the autocompletetextview can be inverted and appears on top of the view, but what's strange is that it usually shows on top of the keyboard not bellow...
I had the same problem with this a little while ago. You Can try manipulating the z-index of the elements that are being hidden to force it to the top which would be your views in this case. Hope it works for you !
another quick solution is by using the attribute "android:dropDownAnchor"
to anchor the dropdown to some other view on top of screen
Add an attribute in your AndroidManifest.xml
android:windowSoftInputMode="adjustPan|adjustResize"
Which will auto resize and adjust the soft keyboard.
Use
android:windowSoftInputMode="adjustPan|adjustResize"
If none of the above solutions worked. try this
android:dropDownHeight="match_parent"
If we didn't mention the dropdown height, it would be considered wrap_content. Therefore the item will show behind the soft keyboard.
Take the autocomplete textviews in respective layouts then you see they opens their values in it only (ABOVE), set autocomplete texview (bottom) of each layouts, as per your question you required three child layouts.
it is really working