I have an EditText inside a RecyclerView. Whenever I press any key on the keyboard, the RecyclerView scroll jumps around.
At first I thought it might be that the list is constantly updating on every key stroke, but that is not the case. I only update the list items once.
Please don't suggest using adjustPan. Yes, that will solve the problem in portrait, since the list isn't very long, but the problem still occurs on small screens or in landscape mode when the list doesn't fit on screen.
I've also tested with and without nestedScrollingEnabled="false", which didn't help either.
Here's a GIF showing what's happening. In this case I'm just pressing the backspace key over and over again.
What is causing this, and how do I prevent it?
Related
I have a RecyclerView in my app. It is part of a fragment (one of several) in an activity. The problem is, when the keyboard is closed it will max out in height and use its internal scroller. When the keyboard opens, the internal scroller turns off and the RecyclerView shows all its children.
The RecyclerView has the option for elements to be added or removed by the end user. In my full implementation, it shows four elements before starting to scroll (with the keyboard closed). When it is the sole fragment, it will max out its height at the screen height.
I've tried setting setting the NestedScrollEnabled to false and while this does stop scrolling, the items it would normally scroll to are no longer accessible. The RecyclerView still changes height depending on keyboard status so the 'hidden' rows become visible when the keyboard is open.
So in short, my RecyclerView is changing its height depending on keyboard visibility. How do I always make it show all its children?
Simplified fragment code that still shows the issue.
Java: https://gist.github.com/anonymous/bd46e137a0fb52f79399c11ba5be61bf
XML: https://gist.github.com/anonymous/c9bfb3f7577f75befc7aa6d5569311ce
I'm using com.android.support:recyclerview-v7:24.2.1
I've encounter an issue using last RecyclerView version.. and even AOSP project don't use the last RecyclerView version.
So ,maybe this will solve your problem, use 23.x.x version and let me know if that resolved the problem :)
I am experiencing a very strange issue with my layout. I have an Activity with a content frame for my app's fragments. Inside one of my fragments I have a ListView with Fast Scroll enabled.
Now, the issue I am having is that the "scroll thumb" (for fasting scrolling) only works in the first fragment that my app shows, and only the first time that fragment is shown.
If I reload the first fragment the scroll thumb disappears. If I switch to a different fragment also containing a ListView with fast scroll, the scroll thumb also disappears.
However, if I reload the entire activity (i.e. close the app and open it again) the problem repeats. It only works once until I reopen my app.
The only partial workaround I've found so far is to use fastScrollAlwaysVisible, in this case the fast scroll is indeed always visible, but that is not the behavior I want. I only want the scroll to show when you scroll in the list.
The left image is the correct scroll behavior, which only works the first time. The right image is the incorrect scroll behavior, where the scroll thumb has disappeared and reverts back to normal scrolling.
Note: before the scroll thumb appears for a very short time when I change to a different fragment.
I stumbled upon the same problem and figured out that Fast Scroll Thumb disappears after the second setting of the android.app.ListActivity.setListAdapter(ListAdapter).
I fixed this by changing cursor of the new ListAdapter first to the empty cursor (having the same columns...) and then to the actual cursor using activity.getListAdapter()).changeCursor(cursor)
Please see the diff of this commit:
https://github.com/andstatus/andstatus/commit/685df904a6c62e656a627e4eb021034f2150ce8f
Please note that the Fast Scroll Thumb doesn't disappear when you don't change ListAdapter, but simply replaces old cursor with a new one using the call: activity.getListAdapter()).changeCursor(cursor);
I am now unable to reproduce the issue. I suspect it might have been fixed with the latest update of Android (4.4.3).
I'm working with a rather large layout that includes a ListView and a LinearLayout beneath it as a footer. I first tried to wrap this in a ScrollView to make the whole layout scrollable, but ran into problems due to both the ListView and the ScrollView being incompatible with each other since they both have scrollable features. So, a workaround was to include the LinearLayout as a footer to the ListView.
Now, in the LinearLayout, I have buttons at various places that the user can click to return to the top of the page. The behaviour I am getting from this is odd, to say the least.
If I have not scrolled down too far, the buttons function normally. However, if I scroll down a bit too far, then clicking the button (even the same buttons that previously worked) will result in the layout scrolling up to roughly half of the way up the listview instead of the top.
Here is the method that does the scrolling, it's rather simple:
public void backToTop(View view) {
lv = (ListView)findViewById(R.id.listview);
lv.smoothScrollToPosition(0);
}
This method is triggered when any of the buttons are clicked.
I have also tried to use the "scrollTo(0, 0)" function, but that failed to do anything.
Any help would be appreciated!
**edit: After testing some more, it appears as though the point where scrolling does not seem to function properly anymore is when the listview is no longer visible on the page. As soon as I scroll past it, the buttons begin to function incorrectly.
Edit 2: SOLVED. My solution: I changed the line
lv.smoothScrollToPosition(0);
to:
lv.setSelected(0);
This seems to give the correct behaviour for all my buttons at any position that the user has placed their screen. Using setSelected does not seem to have the side-effect that I was expecting of automatically triggering the click-event. Hooray!
My solution: I changed the second line of my backToTop method:
lv.smoothScrollToPosition(0);
to:
lv.setSelected(0);
This seems to give the correct behaviour for all my buttons at any position that the user has placed their screen. Using setSelected does not seem to have the side-effect that I was expecting of automatically triggering the click-event. Hooray!
I use a grid view that gathers several check boxes. The grid view is populated using an adapter that is derived from BaseAdapted. Above the grid there is an EditText.
The check boxes function ok in the beginning. But after showing the soft keyboard (by tapping the EditText, then dismissing the keyboard, even without pressing any key) some of the check boxes that were covered by the keyboard stop responding.
Any idea how to solve this?
Thank you very much!
After many trials I gave up the GridView and used instead a TableLayout, creating the TableRows dynamically. No softkeys problem with this solution, it looks exactly the same and behaves the same as a GridView (except for the entire check boxes set is loaded into memory, which might not be the case with a GridView, but still all check boxes were displayed on the activity at once so I don't think there was any memory consumption difference).
In short, TableLayout/TableRow instead of GridView for this purpose looks the same, and even easier to code, since I filled up the TableLayout directly, within a few lines of code, where the GridView required an adapter. Problemo solved, case closed. :-)
I have my listview doing somethings like scrollToPosition , this makes the listview automatically scroll to a part of the list. MOST of the time it works, sometimes it doesn't happen, such as when there are other things happening quickly like button presses or when the scrolling is supposed to happen after a thread ends.
It seems having anything in the way prevents the scrolling. Thoughts, suggestions?