android adjustresize adjustpan famous issue - android

I'm not looking for code, either I won't post any, just an explanation, because I'm kind of lost.
There is this main issue about the resizing when softkeyboard appear.
In my case
I have a listView feeded with 2 editText and many textView with database content using a custom cursorAdapter.
1) AdjustPan
It's pretty simple. When I use the adjustPan property, everything works quite good, except the fact that when I press an editText in my listView and if the listview is bigger than the screensize, I can't scroll. This is actually the normal behaviour and I can understand it.
2) AdjustResize
Here I can scroll as much as I wish.
This property is the one I want to use. But I'm facing 2 issues :
When I press on one of the two editText, I just can't write in. Impossible, even thought it has the focus. I'm forcing the softkeyboard to appear, I try to type some letters in (remember that this editText is focused) but nothing happens.
Again, when I press one of the two editText, it just reorganize (apparently randomly) listview's items. Even thought it's working perfectly with adjustPan, with adjustResize, it's messing with items of the listView.
Any information about one of the 2 issues would be helpful. You can even ask for code, but one more time, I'm just looking for a general explanation that could help. Thanks.

Here this mention issue is same facing me in my app and here some change in my code is this working fine in my app. please try this...
<activity android:name="com.MainActivity"
android:configChanges="orientation|screenSize"/>
<ListView
android:id="#+id/fields_list_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:descendantFocusability="afterDescendants"
android:focusableInTouchMode="true"
android:focusable="true"
/>
<EditText
android:id="#+id/input_edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:cursorVisible="true"
android:gravity="top"
android:inputType="none"
android:textColor="#color/black"/>

Related

Android: TextInputEditText showing text only after change focus

I have a big problem with a EditText that does not show any input until i change focus from element. When I click on the input, the keyboard appears and while i type, there is nothing displayed in the edit text view. The input is shown only when i close the keyboard
It is not a problem of colours. I mention that the view are contained in a constraint layout. I can enable hardware acceleration but this will slow down the application very much and it's not an option. I can however discard the constraint layout and change it to a linear layout but this will affect the rest of the code. I am sure that I am missing something, an easy fix, but i can't put my finger on it. Thanks a lot in advance
<android.support.design.widget.TextInputLayout
android:id="#+id/codeEditTextContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toTopOf="#id/verifyButton"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<android.support.design.widget.TextInputEditText
android:id="#+id/codeEditText"
android:layout_width="match_parent"
android:inputType="text"
android:layout_height="wrap_content"
android:hint="#string/sms_code"
android:padding="10dp"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
!!UPDATE
Found the problem, but still i have no answer. This problem is present only on Android Pie and only when the edit text is in the lower part of the screen and has to be raised by the soft keyboard. I already tried to add softInputWindowMode to adjustResize or adjustPan but this is not doing anything.
The problem itself is a duplicate to this question Android Pie edittext does not adjustPan/resize while typing
which still doesn't have an answer
The problem man be about hardwareAccelerated. I was having the same problem and waste too much time to solve before saw this page.
Android Pie edittext does not adjustPan/resize while typing

Two fragments stacked ontop of each other using transactional ADD - how to prevent edit text gaining focus on bottom fragment?

Try stacking two fragments with editTexts on top of each other using an Add Transaction. after that when you press the keyboard imeOption key next button the bottom fragment's edit text can gain focus. this is a security concern. user can type things into the bottom fragments edit text (blindly). I tried the following code:
android:filterTouchesWhenObscured="true"
but it has not helped at least on api 27.
my edit text itself looks like this, nothing special:
<EditText
android:id="#+id/et"
android:layout_width="195dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:imeOptions="actionNone"
android:layout_marginBottom="10dp"
android:hint="#string/enter_name"
android:filterTouchesWhenObscured="true"
android:inputType="textNoSuggestions"
android:textColorHint="#959595"
android:textSize="11sp" />
the issue is very similar to android tap jacking
i tried even doing this:
android:nextFocusDown="#+id/et_two" thinking it would bypass and go directly to the edittext i want. but instead the bottom edit text still gains focus.
the issue solution was surprising. recyclerview was stealing focus. see this SO incident:
adding android:descendantFocusability="blocksDescendants" to the recyclerview stopped the issue.

Stop EditText from bringing up the keyboard on Activity start?

I have an Edit Text in one of my App layouts, and I want this EditText to only open the keyboard (I believe this is called being focused on?) when it is actually touched.
As of now, the keyboard opens with the EditText whenever the app opens, which isn't what I want.
I have tried many different XML tags to fix this:
android:focusable="false" <--- Prevents keyboard from opening at all.
android:focusable="true"
android:focusableInTouchMode = "true" <--- These tags give me the same result as no tags (keybaord will open on activity start)
android:focusedByDefault = "true" <--- Only available in API >= 23
What I am asking is, why is it so hard to disable default focus on an EditText? Surely I am missing an easy way to do this.
EDIT: Adding this line to my AndroidManifest fixed the issue:
android:windowSoftInputMode="stateHidden"
However, I don't like this solution. It seems like since this is in the Manifest, it will affect more UI elements than the single EditText I need to change.
Alternatively you can set the focus to the root layout element:
android:focusable="true"
android:focusableInTouchMode="true"
Example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<EditText
android:inputType="text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Use android:windowSoftInputMode="stateHidden"
If you dig deep into the Theme you are using for your Activity, you will find that the default value of windowSoftInputMode is stateUnspecified|adjustPan. And from the documentation:
stateUnspecified: Not specified, use what the system thinks is best. This is the default.
So depending on the the android device you run, your results will vary. I tried reproducing your case in API-26 emulator and the keyboard doesn't show up.You can use stateHidden to ensure that when an activity starts, the soft keyboard doesn't show up when the EditText gets focused on itself.
The other way to solve this is to requestFocus to some other element in the UI, making sure the EditText is not the first UI element to get focused. In my experience this is kind of a hack and it messes up the accessibility. The safest and clean way to accomplish is actually to use stateHidden.
stateHidden: Make the soft input area hidden when normally appropriate (when the user is navigating forward to your window).
Note that this will not affect any other UI elements. You can use adjustPan also to this, based on the screen background.

(Android) ScrollView stutters on fling with long multiline EditTtext inside

I have the following problem, and I cannot figure out how to eve try solving it (or whether there is a way):
My problem
I have SrollView, containing to EditText input fields. One is a single line, below is a multiline. Everything's fine and works as expected, up until I put too much stuff into the multiline EditText. When I fast scroll the view, the scrolling skips and stutters, very obviously, the whole effect is rather disturbing. tried on a Galaxy S3 with a custom AOSP ROM, and Note 4 with official 5.1.1, no difference at all.
I would expect a very heavy EditText makes it difficult to smoothly redraw on a fling, but this starts happening with relatively short text (approx 4-5 screen-pages long).
Edit: This also seems to happen on a simple scroll, when I do as much as touch it and move it a few lines (scrolling is not near to being smooth, that is)
The setup
I have reduced the widgets to the bare minimum, even removed padding, only the problem does not improve. From the Java code I also removed anything (any styling, or typeface, anything that affects the widgets at all), still no improvement.
If this is of any significance, the ScrollView in question is inside a fragment, that is one of two pages of a ViewPager. There is nothing else on this fragment ATM.
Here's the XML (as you will see, it's as base as possible):
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"/>
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="false"
android:inputType="textMultiLine"/>
</LinearLayout>
</ScrollView>
What I tried
Any advice I found regards only ListViews, and some attributes like android:smoothScrollbar, which have no effect here (I tried them all).
For the record, I did try out of frustration all of the below ( I know most of these has not much to do with ScrollViews, but I'm becoming hopeless here):
android:hardwareAccelerated="true"
android:fastScrollEnabled="true"
android:scrollingCache="true"
android:smoothScrollbar="true"
and also tried setting from the Java code things like
.setSmoothScrollingEnabled(true);
.fling(3500);
still no luck.
Question recap
Is there any way to make a simple widget like this scroll smoothly at all?
Thanks for your time if you've read through and even more if you answer. :)

Edittext "lag" android

The first time i focus an edittext view i notice a lag of one or two seconds before i can write anything in the textbox.
I notice this behavior even on an app without any code more than what's nessecary to initialize the application.
What am i doing wrong?
I've INSTANTLY fixed this issue for me; I saw in the DDMS that a lot of redraw's and recalculations were occurring while entering text, and a lot of info about RelativeLayouts were being called. So, I checked my layout; i had some Multi-Line EditText's who were direct children of a RelativeLayout. So, I wrapped those up into a Linear Layout, and specified my desired width/height at the LinearLayout, not each EditText.
Guess what? It totally fixed it!!
(below, some code... keep in mind, this is just an approximation. Don't try and copy/paste)
BEFORE:
<RelativeLayout>
<EditText
android:layout_width="wrap_content" />
<EditText
android:layout_width="wrap_content" />
</RelativeLayout>
AFTER:
<RelativeLayout>
<LinearLayout
android:layout_width="wrap_content" >
<EditText
android:layout_width="fill_parent" />
<EditText
android:layout_width="fill_parent" />
</LinearLayout>
</RelativeLayout>
Wrapped my EditText's into a LinearLayout, and relinquished dynamic layout controls to the LinearLayout.
It was an amazing and instant improvement.
Are you using the emulator?
This is common when you are using the emulator regardless of debug mode or not...at least from my (limited) experience so far. Try your app out on a real phone and see what happens.
I turned off USB debugging and uninstalled a few keyboards. Seems to work fine now. Thanks all.
Edit AndroidManifest:
My old code
< uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />
My new code
< uses-sdk android:minSdkVersion="8" />
I just removed the targetSdkVersion and the lag went away.
In my case the symptoms were the same, a delay occurred to present the keyboard and when typing the letters were gradually appearing.
The solution is because I had put a Background image in the RelativeLayout, when I did a test taking the background worked out and stopped the delay, so I entered an online site that reduces photos and then reduced from 93kb to 50kb and worked perfectly.
In my case the problem was the background-drawable for the activity (as dialog) on XML, it was too heavy. changing it, works fine.
In my case, the lag was because of the heavy serialised objects I used to pass in Intent putExtra() of activities in the app. Those would continue to stay in the memory and cause the problem.

Categories

Resources