Popup of AutoCompleteTextView is showing behind keyboard - android

I have an AutoCompleteTextView in my app, at the bottom of the layout.
When user inputs data, suggestion popup with items should appear.
All works as expected on Android Samsung device with OS 6.0.1:
But for Android 8.0.0 (LG device and also an emulator 8.1.0), I don't see such popup, I suppose it showing behind keyboard for some reason (Because when I clicked back button nothing happened - popup handled that event, and only on second back click keyboard disappeared):
My AutocompleteTextview:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout ...
<android.support.v7.widget.AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="#drawable/thin_square_border"
android:maxLines="3"
android:minHeight="60sp"
android:padding="12dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:textColor="#color/charcoalgray"
/>
</LinearLayout>
</ScrollView>
I've tried dropDownAnchor on view above, and android:dropDownHeight="wrap_content" but that didn't help.

I found this solution that works for me in Oreo and Pie.
I added this to my fragment:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
This seems like a bug introduced in Oreo. Hope this helps for your case.

you have to set android:dropDownAnchor="#id/container_comment" in your autocomplete widget

Related

Copy/Paste menu items aren't shown on some devices in Android EditText

I have a subclass of Android EditText and it' declared as:
...
android:id="#+id/Main.editor"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|top"
android:inputType="textMultiLine|textNoSuggestions|textVisiblePassword"
android:imeOptions="flagNoExtractUi"
...
On most devices user are able to do a long click and see a menu with Copy/Paste items:
In emulator:
On device (where it works):
However on some devices it's not shown on long click:
What can be a reason?
I'm thinking about declaring android:longClickable="true" explicitly but i believe it's a default value.
UPDATE: It's reproducible on some Android 9 devices, so it seems to be not that issue: https://issuetracker.google.com/issues/65575880
Android has a default feature to show copy/paste menu
Try with this in your xml android:textIsSelectable.
i.e., android:textIsSelectable="true"

Disable SoftKeyboard while keeping Cursor

I have an EditText and a custom keyboard, so i want to avoid softkeyboard to popping up. It must never pop up, but i need also to leave EditText focusable to use cursor. Simple as it is but so hard to accomplish.
I already tried a lot of solutions but they aren't working and since they are outdated i'm asking now for an actual working way. Solutions targetted as API 11 are such useless now since they don't work, already tried. I'd love to listen for suggestions from people who already tried the method on recent versions, such as Lollipop (API 21-22) or Marshmallow (23). I can't believe that there is no workaround, and i'm getting mad
This will help you
editText.setInputType(InputType.TYPE_NULL);
In your layout file add these line
android:descendantFocusability="beforeDescendants" and
android:focusableInTouchMode="true"
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true" >
<EditText
android:id="#+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
</EditText>
</RelativeLayout>
In your Activity class add this line
this.getWindow().
setSoftInputMode
(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

EditText setError messed up on Samsung phones

So currently only reproducible on a Samsung S5 and a Galaxy note, this is what my EditText setError is
The thing is, I've tried setError on an empty application with an EditText field and it works 100% fine, so it's nothing that Samsung is intrinsically messing up with their libraries. But it does seem like it has to do with how they render their views? I've tested it on a Moto X and other non-samsung phones (including nexus 7 tablet) and it works fine!
When I click away and then back into the EditText, it then "messes" up again to this:
However, when I click and open the keyboard, rotate the screen into landscape, then back into portrait with the keyboard still up, the setError comes back to normal like so:
So I'm thinking it has to do with how we render our views or some boundary somewhere. I've already tried requestLayout(), forceLayout(), and invalidate() the view on edittext. Also tried invalidate() on the whole view. Still nothing. Any ideas/where to investigate? Thanks all
EDIT: Here's the XML Layout for the just the LinearLayout stuff
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="5"
android:gravity="center"
android:paddingTop="#dimen/location_padding_top"
android:paddingBottom="100dp"
>
<EditText
android:id="#+id/location"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="number"
android:hint="Zip Code"
android:maxLength="5"
android:textSize="#dimen/field_text_size"
android:layout_weight="2"
/>
<ImageView
android:id="#+id/my_location_image"
android:src="#drawable/ic_menu_gps_blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>

Android alert dialog not styled properly on Lollipop

I have tried everything to get this working and cannot figure it out.
I am trying to use an alert dialog im my app. It works fine on KitKat but not on Lollipop.
I have even tried using many material dialogs on GitHub and again they work on Kitkat but not on Lollipop.
I am testing on my Nexus 5 with stock nexus factory image.
KITKAT WITH GITHUB MATERIAL DIALOG
KITKAT WITH STOCK ALERT DIALOG
LOLLIPOP WITH GITHUB MATERIAL DIALOG
LOLLIPOP WITH STOCK ALERT DIALOG
Also this is the library on github installed on the same device its not working on. So its something about my app that is causing this. what could it be
android:fitsSystemWindows="true" was the culprit.
I had that declared in my styles.xml.
Removed it from styles.xml and placed in my layout and it working now.
I had the same problem and didn't find any fitsSystemWindows on any of my styles.xml.
To solve it i had to wrap the Layout in a FrameLayout and add the margins to the Layout like this:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/dialog_margin_title"
android:layout_marginBottom="#dimen/dialog_margin"
android:layout_marginLeft="#dimen/dialog_margin"
android:layout_marginStart="#dimen/dialog_margin"
android:layout_marginRight="#dimen/dialog_margin"
android:layout_marginEnd="#dimen/dialog_margin"
android:orientation="vertical">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please enter the email address of the person you would like to follow, this person will be notified." />
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
</LinearLayout>
</FrameLayout>

Android EditText - Text overlay issue

I am seeing a weird bug in my app and I was wondering if someone could help me fix it. I have a simple EditText with some existing Text, if I move the cursor to the top and hit the Enter key it moves the first line down and on top of the second line. I made a video to help with the visual of what I am seeing:
https://www.youtube.com/watch?v=vJfTDjBxdT4&feature=youtube_gdata_player
The phone is a stock Samsung Galaxy Nexus. I have tried to change the InputType to various other things but they all see to have the same issue. Here is the layout:
<EditText
android:id="#+id/editor_text"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="0.72"
android:gravity="top"
android:inputType="textMultiLine|textCapSentences|textAutoCorrect"
android:singleLine="false" >
</EditText>
This is a Jelly Bean issue with Hardware Acceleration here is the Google link:
http://code.google.com/p/android/issues/detail?id=38770
I verified that using the Software layer fixed the issue for me.

Categories

Resources