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).
Related
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?
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 :)
When I click on a row in a vertical list RecyclerView, I call remove the item from the backing list, and call adapter.notifyItemRemoved(position). When position == 0 the move animation is called, otherwise remove animation is called.
In both cases, after that animation is called, an add animation is called for all other visible items on the screen. This makes the remove animation look bad, because all other items flash while the remove animation is being run.
Anyone know what could be causing that?
That does not make sense.
If you remove item at 0 (assuming it is visible and top item), there would be a "remove" for that item and "move" animation for all other visible views + one more (the new item to fill the new space but it comes with a move animation from below the list).
Can you post some code?
I was using TwoWayView (github.com/lucasr/twoway-view). I've had too much trouble with it, and removing it seems to have fixed any trouble I was having, including this issue.
Filed an issue with the project on Github here.
I need a component that works like the picture below but I'm having trouble coming up with some kind of decent solution that works.
I want the list to have a center locked selection but being scrollable with the d-pad. This is for an application running on a TV so no need for touch scroll. So when pressing down on the remote d-pad the list will scroll and a new item will size up and the current selected one will size down and the new selection will still be in the middle.
I've tried doing this using a ListView that I extended and programmatically scrolling when pressing down or up. On scroll finished I called notifyDatasetChanged() on the ListView for re-inflating of the childs and in the ListViews adapters getView() I made the animation of the view located at the current selected position.
This is not optimal since I need to call notifyDatasetChanged(), which re-inflates all visible views, for the animation to apply. The UI becomes laggy when doing this and scrolling fast. It's also not possible to make som kind of compress animation when current selected item goes out of selection. There is also some trouble with the end items (read views) such the first or last in the list when doing animation of them, the may sometimes go out of screen.
I think that his must have been done before and maybe I'm missing it when searching for an answer.
Have anyone done something similar or do you have some suggestions of how this can be achieved? Maybe I'm just starting of with the wrong component here..
Regards,
Kristoffer
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!